1138 if (SvdMatrixProductP) {
1147 int i, N = Matrix.
GetCols(), K = 0;
1148 double t = 0.0, eps = 1e-6;
1152 double tmp = 1/sqrt((
double)N);
1153 for (i = 0; i < N; i++) {
1158 TIntV CountConvgV(Iters);
1159 for (i = 0; i < Iters; i++) CountConvgV[i] = 0;
1163 TFltV d(Iters+1), e(Iters+1);
1169 TFltV z(N), bb(Iters), aa(Iters), y(N);
1172 if (SvdMatrixProductP) {
1180 for (
int j = 0; j < (Iters-1); j++) {
1195 for (i = 0; i <= j; i++) {
1198 (bb[j-1] *
TFlt::Abs(V(K-1, i)) < eps * t)) {
1200 ConvgQV[i].Reserve(N,N); CountConvgV[i]++;
1201 TFltV& vec = ConvgQV[i];
1203 for (
int k = 0; k < N; k++) {
1205 for (
int l = 0; l < K; l++) {
1206 vec[k] += Q(k,l) * V(l,i);
1217 if (!(bb[j] > 1e-10)) {
1218 printf(
"Rank of matrix is only %d\n", j+2);
1219 printf(
"Last singular value is %g\n", bb[j].Val);
1223 for (i = 0; i < N; i++) {
1224 Q(i, j+1) = z[i] / bb[j];
1228 if (SvdMatrixProductP) {
1239 for (i = 1; i < K; i++) d[i] = aa[i-1];
1243 for (i = 2; i <= K; i++) e[i] = bb[i-2];
1247 for (i = 2; i < K; i++) {
1253 for (i = 0; i < K; i++) {
1254 for (
int k = 0; k < K; k++) {
1268 for (i = 0; i < K; i++) {
1276 EigValV.
Reserve(FinalNumEig,0);
1278 for (i = 0; i < FinalNumEig; i++) {
1281 double sigma = d[ii+1].Val;
static double Norm(const TFltV &x)
#define IAssertR(Cond, Reason)
static double GetMx(const double &Flt1, const double &Flt2)
static int GetMn(const int &Int1, const int &Int2)
static void AddVec(const double &k, const TFltV &x, const TFltV &y, TFltV &z)
static void EigSymmetricTridiag(TFltV &d, TFltV &e, int n, TFltVV &z)
void Gen(const int &_XDim, const int &_YDim)
static void Multiply(const TFltVV &A, const TFltV &x, TFltV &y)
static double Abs(const double &Flt)
void Multiply(const TFltVV &B, int ColId, TFltV &Result) const
static TStr Fmt(const char *FmtStr,...)
static double DotProduct(const TFltV &x, const TFltV &y)
void Reserve(const TSizeTy &_MxVals)
Reserves enough memory for the vector to store _MxVals elements.
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
static void MultiplyATA(const TMatrix &Matrix, const TFltVV &Vec, int ColId, TFltV &Result)
Vector is a sequence TVal objects representing an array that can change in size.