18 #define REPORT { static ExeCounter ExeCount(__LINE__,15); ++ExeCount; } 27 bool withU,
bool withV)
32 Real eps = FloatingPointPrecision::Epsilon();
35 int m =
A.Nrows();
int n =
A.Ncols();
38 if (withV && &U == &V)
51 f = UCI.
First(); g = -
sign(sqrt(s), f); h = f*g-s; UCI.
First() = f-g;
57 if (s<tol) {
REPORT g = 0.0; }
76 for (i=
n-2; i>=0; i--)
94 for (i=
n-1; i>=0; i--)
103 UCI.
Up(); UCJ.Up(); UCJ.AddScaled(UCI,s/h);
115 for (
int k=
n-1; k>=0; k--)
118 Real y;
int limit = 50;
int l = 0;
121 Real c, s;
int i;
int l1=k;
bool tfc=
false;
132 l=l1; l1=l-1; s = -1.0; c = 0.0;
137 if (fabs(f)<=eps) {
REPORT break; }
152 f = ((
y-z)*(
y+z) + (g-h)*(g+h)) / (2*h*
y);
154 else if (f<-1) {
REPORT g = -f * sqrt(1 +
square(1/f)); }
155 else {
REPORT g = sqrt(f*f + 1); }
156 {
REPORT f = ((
x-z)*(
x+z) + h*(
y / ((f<0.0) ? f-g : f+g)-h)) /
x; }
159 for (i=l+1; i<=k; i++)
163 f =
x*c + g*s; g = -
x*s + g*c; h =
y*s;
y *= c;
171 f = c*g + s*
y;
x = -s*g + c*
y;
190 if (withU & withV)
SortSV(Q, U, V);
191 else if (withU)
SortSV(Q, U);
192 else if (withV)
SortSV(Q, V);
Real sign(Real x, Real y)
void SVD(const Matrix &A, DiagonalMatrix &Q, Matrix &U, Matrix &V, bool withU, bool withV)
Real Maximum(const BaseMatrix &B)
Real pythag(Real f, Real g, Real &c, Real &s)
void Reset(const Matrix &, int, int, int)
virtual void ReSize(int, int)
void ComplexScale(RectMatrixCol &U, RectMatrixCol &V, Real x, Real y)
os2<< "> n<< " > nendobj n
void Divide(const RectMatrixRowCol &, Real)
void AddScaled(const RectMatrixRowCol &, Real)
void SortDescending(GeneralMatrix &)
Real Minimum(const BaseMatrix &B)
void SortSV(DiagonalMatrix &D, Matrix &U, bool ascending=false)