00001
00043
00044
00045 #include <cmath>
00046 #include <SharkDefs.h>
00047 #include <LinAlg/LinAlg.h>
00048
00049 #ifdef _WINDOWS
00050
00051 #pragma warning(disable: 4100)
00052 #endif
00053
00054
00095 unsigned svdrank
00096 (
00097 const Array2D< double >& amatA,
00098 Array2D< double >& umatA,
00099 Array2D< double >& vmatA,
00100 Array < double >& wvecA
00101 )
00102 {
00103
00104 unsigned n = amatA.cols();
00105
00106
00107
00108
00109
00110 unsigned r;
00111 double s, t;
00112
00113
00114
00115
00116
00117
00118
00119
00120 for (r = 0; r < n && wvecA( r ) > 0.; r++);
00121
00122 t = r < n ? fabs(wvecA( n-1 )) : 0.0;
00123 r = 0;
00124 s = 0.0;
00125 while (r < n &&
00126 wvecA( r ) > t &&
00127 wvecA( r ) + s > s)
00128 s += wvecA( r++ );
00129
00130 return r;
00131 }
00132
00133
00134
00135
00136
00137