@@ -73,6 +73,22 @@ Bryant
7373 double d1 = colval1, d2 = colval2; \
7474 colval1 = d1*cos0 + d2*sin0; colval2 = -d1*sin0 + d2*cos0; \
7575 }
76+ #define PRINTMAT (M , colind , rowind , ncols , nrows ) \
77+ printf(#M ":\n"); \
78+ for (rowind=0;rowind<nrows;rowind++) { \
79+ for (colind=0;colind<ncols;colind++) \
80+ printf("%4.2g ",M[rowind*ncols + colind]); \
81+ printf("\n"); \
82+ }
83+ #define PRINTVEC (V , colind , ncols ) \
84+ printf(#V " vector:\n"); \
85+ for (colind=0;colind<ncols;colind++) \
86+ printf("%4.2g ",V[colind]); \
87+ printf("\n");
88+
89+ #if DEBUG
90+ #include <stdio.h>
91+ #endif
7692
7793void SVD (double * U , double * V , double * Z , int nRow , int nCol )
7894{
@@ -91,6 +107,10 @@ void SVD(double *U, double *V, double *Z, int nRow, int nCol)
91107 for (i = 0 ; i < nCol ; i ++ )
92108 for (j = 0 ; j < nCol ; j ++ )
93109 V [ nCol * i + j ] = i == j ? 1.0 : 0.0 ;
110+ #if DEBUG
111+ printf ("BEFORE " ); PRINTMAT (U , j , i , nCol , nRow )
112+ printf ("BEFORE " ); PRINTMAT (V , j , i , nCol , nCol )
113+ #endif
94114 RotCount = EstColRank * (EstColRank - 1 )/2 ;
95115 /*until convergence is achieved or too many sweeps are carried out*/
96116 while (RotCount != 0 && SweepCount <= slimit ) {
@@ -177,6 +197,9 @@ void SVD(double *U, double *V, double *Z, int nRow, int nCol)
177197#if DEBUG
178198 if (SweepCount > slimit )
179199 fprintf (stderr , "Sweeps = %d\n" , SweepCount );
200+ printf ("AFTER " ); PRINTMAT (U , j , i , nCol , nRow )
201+ printf ("AFTER " ); PRINTMAT (V , j , i , nCol , nCol )
202+ PRINTVEC (Z , j , nCol )
180203#endif
181204}
182205
@@ -187,18 +210,6 @@ void SVD(double *U, double *V, double *Z, int nRow, int nCol)
187210#define NR 2
188211#define NC2 2
189212#define NR2 3
190- #define PRINTMAT (M , colind , rowind , ncols , nrows ) \
191- printf(#M ":\n"); \
192- for (rowind=0;rowind<nrows;rowind++) { \
193- for (colind=0;colind<ncols;colind++) \
194- printf("%4.2g ",M[rowind*ncols + colind]); \
195- printf("\n"); \
196- }
197- #define PRINTVEC (V , colind , ncols ) \
198- printf(#V " vector:\n"); \
199- for (colind=0;colind<ncols;colind++) \
200- printf("%4.2g ",V[colind]); \
201- printf("\n");
202213int main ()
203214{
204215 int i ,j ;
0 commit comments