22 #define REPORT { static ExeCounter ExeCount(__LINE__,15); ++ExeCount; } 31 bool withU,
bool withV)
42 if (withV && &U == &V)
55 f = UCI.
First(); g = -
sign(sqrt(s), f); h = f*g-s; UCI.
First() = f-g;
61 if (s<tol) {
REPORT g = 0.0; }
71 if (++i == n) {
REPORT break; }
80 for (i=n-2; i>=0; i--)
98 for (i=n-1; i>=0; i--)
107 UCI.
Up(); UCJ.Up(); UCJ.AddScaled(UCI,s/h);
119 for (
int k=n-1; k>=0; k--)
122 Real y;
int limit = 50;
int l = 0;
125 Real c, s;
int i;
int l1=k;
bool tfc=
false;
136 l=l1; l1=l-1; s = -1.0; c = 0.0;
141 if (fabs(f)<=eps) {
REPORT break; }
156 f = ((y-z)*(y+z) + (g-h)*(g+h)) / (2*h*y);
158 else if (f<-1) {
REPORT g = -f * sqrt(1 +
square(1/f)); }
159 else {
REPORT g = sqrt(f*f + 1); }
160 {
REPORT f = ((x-z)*(x+z) + h*(y / ((f<0.0) ? f-g : f+g)-h)) / x; }
163 for (i=l+1; i<=k; i++)
167 f = x*c + g*s; g = -x*s + g*c; h = y*s; y *= c;
175 f = c*g + s*y; x = -s*g + c*y;
194 if (withU & withV)
SortSV(Q, U, V);
195 else if (withU)
SortSV(Q, U);
196 else if (withV)
SortSV(Q, V);
Miscellaneous exception (details in character string).
void SVD(const Matrix &A, DiagonalMatrix &Q, Matrix &U, Matrix &V, bool withU, bool withV)
virtual void ReSize(int m, int n)
Real pythag(Real f, Real g, Real &c, Real &s)
void Reset(const Matrix &, int, int, int)
void ComplexScale(RectMatrixCol &U, RectMatrixCol &V, Real x, Real y)
void sort_descending(GeneralMatrix &)
void Divide(const RectMatrixRowCol &, Real)
The usual rectangular matrix.
Real trace(const BaseMatrix &B)
Covergence failure exception.
void AddScaled(const RectMatrixRowCol &, Real)
void SortSV(DiagonalMatrix &D, Matrix &U, bool ascending=false)