18 template<
unsigned int Precision>
20 template<
unsigned int Precision>
25 template<
unsigned int Precision>
35 template<
unsigned int Precision>
44 template<
unsigned int Precision>
46 template<
unsigned int Precision>
57 template<
unsigned int Precision>
96 for(gpass=1; gpass<=1; gpass++)
102 for(
i=0;
i<=maxmn-1;
i++)
104 for(
j=0;
j<=maxmn-1;
j++)
113 testsvdproblem<Precision>(a,
i,
j, materr, orterr, othererr, wsorted, wfailed);
120 for(
i=0;
i<=maxmn-1;
i++)
127 for(
i=1;
i<=maxmn;
i++)
131 testsvdproblem<Precision>(a,
i,
j, materr, orterr, othererr, wsorted, wfailed);
136 for(
j=0;
j<=maxmn-1;
j++)
143 for(
j=1;
j<=maxmn;
j++)
145 testsvdproblem<Precision>(a,
i,
j, materr, orterr, othererr, wsorted, wfailed);
156 for(
i=0;
i<=
m-1;
i++)
158 for(
j=0;
j<=n-1;
j++)
163 testsvdproblem<Precision>(a,
m, n, materr, orterr, othererr, wsorted, wfailed);
174 for(pass=1; pass<=2; pass++)
177 testsvdproblem<Precision>(a,
m, n, materr, orterr, othererr, wsorted, wfailed);
179 testsvdproblem<Precision>(a,
m, n, materr, orterr, othererr, wsorted, wfailed);
181 testsvdproblem<Precision>(a,
m, n, materr, orterr, othererr, wsorted, wfailed);
191 waserrors = materr>threshold || orterr>threshold || othererr>threshold || !wsorted || failr>failthreshold;
194 printf(
"TESTING SVD DECOMPOSITION\n");
195 printf(
"SVD decomposition error: %5.3le\n",
197 printf(
"SVD orthogonality error: %5.3le\n",
199 printf(
"SVD with different parameters error: %5.3le\n",
201 printf(
"Singular values order: ");
210 printf(
"Always converged: ");
218 printf(
"Fail ratio: %5.3lf\n",
221 printf(
"Threshold: %5.3le\n",
225 printf(
"TEST FAILED\n");
229 printf(
"TEST PASSED\n");
238 template<
unsigned int Precision>
248 for(
i=0;
i<=
m-1;
i++)
250 for(
j=0;
j<=n-1;
j++)
265 template<
unsigned int Precision>
290 for(
i=0;
i<=
m-1;
i++)
292 for(
j=0;
j<=n-1;
j++)
295 for(
k=0;
k<=minmn-1;
k++)
297 sm = sm+
w(
k)*u(
i,
k)*vt(
k,
j);
299 locerr = amp::maximum<Precision>(locerr, amp::abs<Precision>(a(
i,
j)-sm));
302 materr = amp::maximum<Precision>(materr, locerr);
308 for(
i=0;
i<=minmn-1;
i++)
310 for(
j=
i;
j<=minmn-1;
j++)
315 locerr = amp::maximum<Precision>(locerr, amp::abs<Precision>(sm));
319 locerr = amp::maximum<Precision>(locerr, amp::abs<Precision>(sm-1));
324 locerr = amp::maximum<Precision>(locerr, amp::abs<Precision>(sm));
328 locerr = amp::maximum<Precision>(locerr, amp::abs<Precision>(sm-1));
332 orterr = amp::maximum<Precision>(orterr, locerr);
337 for(
i=1;
i<=minmn-1;
i++)
347 template<
unsigned int Precision>
379 if( !svd::rmatrixsvd<Precision>(a,
m, n, 2, 2, 2,
w, u, vt) )
385 getsvderror<Precision>(a,
m, n, u,
w, vt, materr, orterr, wsorted);
390 for(ujob=0; ujob<=2; ujob++)
392 for(vtjob=0; vtjob<=2; vtjob++)
394 for(memjob=0; memjob<=2; memjob++)
396 if( !svd::rmatrixsvd<Precision>(a,
m, n, ujob, vtjob, memjob, w2, u2, vt2) )
420 for(
i=0;
i<=
m-1;
i++)
422 for(
j=0;
j<=ucheck-1;
j++)
424 othererr = amp::maximum<Precision>(othererr, amp::abs<Precision>(u(
i,
j)-u2(
i,
j)));
427 for(
i=0;
i<=vtcheck-1;
i++)
429 for(
j=0;
j<=n-1;
j++)
431 othererr = amp::maximum<Precision>(othererr, amp::abs<Precision>(vt(
i,
j)-vt2(
i,
j)));
436 othererr = amp::maximum<Precision>(othererr, amp::abs<Precision>(
w(
i)-w2(
i)));
452 template<
unsigned int Precision>
458 result = testsvd<Precision>(
true);
466 template<
unsigned int Precision>
472 result = testsvd<Precision>(
false);
static const ampf getAlgoPascalEpsilon()
static const ampf getRandom()
void setbounds(int iLow1, int iHigh1, int iLow2, int iHigh2)
const Variable & v
< [in] a sqrfree bivariate poly
T vdotproduct(const_raw_vector< T > v1, const_raw_vector< T > v2)
int minint(int m1, int m2)
void fillsparsea(ap::template_2d_array< amp::ampf< Precision > > &a, int m, int n, amp::ampf< Precision > sparcity)
bool testsvd(bool silent)
void getsvderror(const ap::template_2d_array< amp::ampf< Precision > > &a, int m, int n, const ap::template_2d_array< amp::ampf< Precision > > &u, const ap::template_1d_array< amp::ampf< Precision > > &w, const ap::template_2d_array< amp::ampf< Precision > > &vt, amp::ampf< Precision > &materr, amp::ampf< Precision > &orterr, bool &wsorted)
bool testsvdunit_test_silent()
void testsvdproblem(const ap::template_2d_array< amp::ampf< Precision > > &a, int m, int n, amp::ampf< Precision > &materr, amp::ampf< Precision > &orterr, amp::ampf< Precision > &othererr, bool &wsorted, bool &wfailed)