65 template<
unsigned int Precision>
75 template<
unsigned int Precision>
139 template<
unsigned int Precision>
145 int additionalmemory,
182 w.setbounds(1, minmn);
189 u.setbounds(0, nru-1, 0, ncu-1);
195 u.setbounds(0, nru-1, 0, ncu-1);
203 vt.setbounds(0, nrvt-1, 0, ncvt-1);
209 vt.setbounds(0, nrvt-1, 0, ncvt-1);
224 qr::rmatrixqr<Precision>(a,
m, n,
tau);
225 for(
i=0;
i<=n-1;
i++)
227 for(
j=0;
j<=
i-1;
j++)
232 bidiagonal::rmatrixbd<Precision>(a, n, n, tauq, taup);
233 bidiagonal::rmatrixbdunpackpt<Precision>(a, n, n, taup, nrvt, vt);
234 bidiagonal::rmatrixbdunpackdiagonals<Precision>(a, n, n, isupper,
w, e);
235 result = bdsvd::rmatrixbdsvd<Precision>(
w, e, n, isupper,
false, u, 0, a, 0, vt, ncvt);
244 qr::rmatrixqr<Precision>(a,
m, n,
tau);
245 qr::rmatrixqrunpackq<Precision>(a,
m, n,
tau, ncu, u);
246 for(
i=0;
i<=n-1;
i++)
248 for(
j=0;
j<=
i-1;
j++)
253 bidiagonal::rmatrixbd<Precision>(a, n, n, tauq, taup);
254 bidiagonal::rmatrixbdunpackpt<Precision>(a, n, n, taup, nrvt, vt);
255 bidiagonal::rmatrixbdunpackdiagonals<Precision>(a, n, n, isupper,
w, e);
256 if( additionalmemory<1 )
262 bidiagonal::rmatrixbdmultiplybyq<Precision>(a, n, n, tauq, u,
m, n,
true,
false);
263 result = bdsvd::rmatrixbdsvd<Precision>(
w, e, n, isupper,
false, u,
m, a, 0, vt, ncvt);
272 bidiagonal::rmatrixbdunpackq<Precision>(a, n, n, tauq, n, t2);
273 blas::copymatrix<Precision>(u, 0,
m-1, 0, n-1, a, 0,
m-1, 0, n-1);
274 blas::inplacetranspose<Precision>(t2, 0, n-1, 0, n-1, work);
275 result = bdsvd::rmatrixbdsvd<Precision>(
w, e, n, isupper,
false, u, 0, t2, n, vt, ncvt);
276 blas::matrixmatrixmultiply<Precision>(a, 0,
m-1, 0, n-1,
false, t2, 0, n-1, 0, n-1,
true,
amp::ampf<Precision>(
"1.0"), u, 0,
m-1, 0, n-1,
amp::ampf<Precision>(
"0.0"), work);
294 lq::rmatrixlq<Precision>(a,
m, n,
tau);
295 for(
i=0;
i<=
m-1;
i++)
297 for(
j=
i+1;
j<=
m-1;
j++)
302 bidiagonal::rmatrixbd<Precision>(a,
m,
m, tauq, taup);
303 bidiagonal::rmatrixbdunpackq<Precision>(a,
m,
m, tauq, ncu, u);
304 bidiagonal::rmatrixbdunpackdiagonals<Precision>(a,
m,
m, isupper,
w, e);
306 blas::inplacetranspose<Precision>(u, 0, nru-1, 0, ncu-1, work);
307 result = bdsvd::rmatrixbdsvd<Precision>(
w, e,
m, isupper,
false, a, 0, u, nru, vt, 0);
308 blas::inplacetranspose<Precision>(u, 0, nru-1, 0, ncu-1, work);
317 lq::rmatrixlq<Precision>(a,
m, n,
tau);
318 lq::rmatrixlqunpackq<Precision>(a,
m, n,
tau, nrvt, vt);
319 for(
i=0;
i<=
m-1;
i++)
321 for(
j=
i+1;
j<=
m-1;
j++)
326 bidiagonal::rmatrixbd<Precision>(a,
m,
m, tauq, taup);
327 bidiagonal::rmatrixbdunpackq<Precision>(a,
m,
m, tauq, ncu, u);
328 bidiagonal::rmatrixbdunpackdiagonals<Precision>(a,
m,
m, isupper,
w, e);
330 blas::inplacetranspose<Precision>(u, 0, nru-1, 0, ncu-1, work);
331 if( additionalmemory<1 )
337 bidiagonal::rmatrixbdmultiplybyp<Precision>(a,
m,
m, taup, vt,
m, n,
false,
true);
338 result = bdsvd::rmatrixbdsvd<Precision>(
w, e,
m, isupper,
false, a, 0, u, nru, vt, n);
346 bidiagonal::rmatrixbdunpackpt<Precision>(a,
m,
m, taup,
m, t2);
347 result = bdsvd::rmatrixbdsvd<Precision>(
w, e,
m, isupper,
false, a, 0, u, nru, t2,
m);
348 blas::copymatrix<Precision>(vt, 0,
m-1, 0, n-1, a, 0,
m-1, 0, n-1);
349 blas::matrixmatrixmultiply<Precision>(t2, 0,
m-1, 0,
m-1,
false, a, 0,
m-1, 0, n-1,
false,
amp::ampf<Precision>(
"1.0"), vt, 0,
m-1, 0, n-1,
amp::ampf<Precision>(
"0.0"), work);
351 blas::inplacetranspose<Precision>(u, 0, nru-1, 0, ncu-1, work);
362 bidiagonal::rmatrixbd<Precision>(a,
m, n, tauq, taup);
363 bidiagonal::rmatrixbdunpackq<Precision>(a,
m, n, tauq, ncu, u);
364 bidiagonal::rmatrixbdunpackpt<Precision>(a,
m, n, taup, nrvt, vt);
365 bidiagonal::rmatrixbdunpackdiagonals<Precision>(a,
m, n, isupper,
w, e);
367 blas::inplacetranspose<Precision>(u, 0, nru-1, 0, ncu-1, work);
368 result = bdsvd::rmatrixbdsvd<Precision>(
w, e, minmn, isupper,
false, a, 0, u, nru, vt, ncvt);
369 blas::inplacetranspose<Precision>(u, 0, nru-1, 0, ncu-1, work);
376 bidiagonal::rmatrixbd<Precision>(a,
m, n, tauq, taup);
377 bidiagonal::rmatrixbdunpackq<Precision>(a,
m, n, tauq, ncu, u);
378 bidiagonal::rmatrixbdunpackpt<Precision>(a,
m, n, taup, nrvt, vt);
379 bidiagonal::rmatrixbdunpackdiagonals<Precision>(a,
m, n, isupper,
w, e);
380 if( additionalmemory<2 || uneeded==0 )
386 result = bdsvd::rmatrixbdsvd<Precision>(
w, e, minmn, isupper,
false, u, nru, a, 0, vt, ncvt);
395 blas::copyandtranspose<Precision>(u, 0,
m-1, 0, minmn-1, t2, 0, minmn-1, 0,
m-1);
396 result = bdsvd::rmatrixbdsvd<Precision>(
w, e, minmn, isupper,
false, u, 0, t2,
m, vt, ncvt);
397 blas::copyandtranspose<Precision>(t2, 0, minmn-1, 0,
m-1, u, 0,
m-1, 0, minmn-1);
407 template<
unsigned int Precision>
413 int additionalmemory,
450 w.setbounds(1, minmn);
457 u.setbounds(1, nru, 1, ncu);
463 u.setbounds(1, nru, 1, ncu);
471 vt.setbounds(1, nrvt, 1, ncvt);
477 vt.setbounds(1, nrvt, 1, ncvt);
492 qr::qrdecomposition<Precision>(a,
m, n,
tau);
495 for(
j=1;
j<=
i-1;
j++)
500 bidiagonal::tobidiagonal<Precision>(a, n, n, tauq, taup);
501 bidiagonal::unpackptfrombidiagonal<Precision>(a, n, n, taup, nrvt, vt);
502 bidiagonal::unpackdiagonalsfrombidiagonal<Precision>(a, n, n, isupper,
w, e);
503 result = bdsvd::bidiagonalsvddecomposition<Precision>(
w, e, n, isupper,
false, u, 0, a, 0, vt, ncvt);
512 qr::qrdecomposition<Precision>(a,
m, n,
tau);
513 qr::unpackqfromqr<Precision>(a,
m, n,
tau, ncu, u);
516 for(
j=1;
j<=
i-1;
j++)
521 bidiagonal::tobidiagonal<Precision>(a, n, n, tauq, taup);
522 bidiagonal::unpackptfrombidiagonal<Precision>(a, n, n, taup, nrvt, vt);
523 bidiagonal::unpackdiagonalsfrombidiagonal<Precision>(a, n, n, isupper,
w, e);
524 if( additionalmemory<1 )
530 bidiagonal::multiplybyqfrombidiagonal<Precision>(a, n, n, tauq, u,
m, n,
true,
false);
531 result = bdsvd::bidiagonalsvddecomposition<Precision>(
w, e, n, isupper,
false, u,
m, a, 0, vt, ncvt);
540 bidiagonal::unpackqfrombidiagonal<Precision>(a, n, n, tauq, n, t2);
541 blas::copymatrix<Precision>(u, 1,
m, 1, n, a, 1,
m, 1, n);
542 blas::inplacetranspose<Precision>(t2, 1, n, 1, n, work);
543 result = bdsvd::bidiagonalsvddecomposition<Precision>(
w, e, n, isupper,
false, u, 0, t2, n, vt, ncvt);
544 blas::matrixmatrixmultiply<Precision>(a, 1,
m, 1, n,
false, t2, 1, n, 1, n,
true,
amp::ampf<Precision>(
"1.0"), u, 1,
m, 1, n,
amp::ampf<Precision>(
"0.0"), work);
562 lq::lqdecomposition<Precision>(a,
m, n,
tau);
563 for(
i=1;
i<=
m-1;
i++)
565 for(
j=
i+1;
j<=
m;
j++)
570 bidiagonal::tobidiagonal<Precision>(a,
m,
m, tauq, taup);
571 bidiagonal::unpackqfrombidiagonal<Precision>(a,
m,
m, tauq, ncu, u);
572 bidiagonal::unpackdiagonalsfrombidiagonal<Precision>(a,
m,
m, isupper,
w, e);
574 blas::inplacetranspose<Precision>(u, 1, nru, 1, ncu, work);
575 result = bdsvd::bidiagonalsvddecomposition<Precision>(
w, e,
m, isupper,
false, a, 0, u, nru, vt, 0);
576 blas::inplacetranspose<Precision>(u, 1, nru, 1, ncu, work);
585 lq::lqdecomposition<Precision>(a,
m, n,
tau);
586 lq::unpackqfromlq<Precision>(a,
m, n,
tau, nrvt, vt);
587 for(
i=1;
i<=
m-1;
i++)
589 for(
j=
i+1;
j<=
m;
j++)
594 bidiagonal::tobidiagonal<Precision>(a,
m,
m, tauq, taup);
595 bidiagonal::unpackqfrombidiagonal<Precision>(a,
m,
m, tauq, ncu, u);
596 bidiagonal::unpackdiagonalsfrombidiagonal<Precision>(a,
m,
m, isupper,
w, e);
598 blas::inplacetranspose<Precision>(u, 1, nru, 1, ncu, work);
599 if( additionalmemory<1 )
605 bidiagonal::multiplybypfrombidiagonal<Precision>(a,
m,
m, taup, vt,
m, n,
false,
true);
606 result = bdsvd::bidiagonalsvddecomposition<Precision>(
w, e,
m, isupper,
false, a, 0, u, nru, vt, n);
614 bidiagonal::unpackptfrombidiagonal<Precision>(a,
m,
m, taup,
m, t2);
615 result = bdsvd::bidiagonalsvddecomposition<Precision>(
w, e,
m, isupper,
false, a, 0, u, nru, t2,
m);
616 blas::copymatrix<Precision>(vt, 1,
m, 1, n, a, 1,
m, 1, n);
617 blas::matrixmatrixmultiply<Precision>(t2, 1,
m, 1,
m,
false, a, 1,
m, 1, n,
false,
amp::ampf<Precision>(
"1.0"), vt, 1,
m, 1, n,
amp::ampf<Precision>(
"0.0"), work);
619 blas::inplacetranspose<Precision>(u, 1, nru, 1, ncu, work);
630 bidiagonal::tobidiagonal<Precision>(a,
m, n, tauq, taup);
631 bidiagonal::unpackqfrombidiagonal<Precision>(a,
m, n, tauq, ncu, u);
632 bidiagonal::unpackptfrombidiagonal<Precision>(a,
m, n, taup, nrvt, vt);
633 bidiagonal::unpackdiagonalsfrombidiagonal<Precision>(a,
m, n, isupper,
w, e);
635 blas::inplacetranspose<Precision>(u, 1, nru, 1, ncu, work);
636 result = bdsvd::bidiagonalsvddecomposition<Precision>(
w, e, minmn, isupper,
false, a, 0, u, nru, vt, ncvt);
637 blas::inplacetranspose<Precision>(u, 1, nru, 1, ncu, work);
644 bidiagonal::tobidiagonal<Precision>(a,
m, n, tauq, taup);
645 bidiagonal::unpackqfrombidiagonal<Precision>(a,
m, n, tauq, ncu, u);
646 bidiagonal::unpackptfrombidiagonal<Precision>(a,
m, n, taup, nrvt, vt);
647 bidiagonal::unpackdiagonalsfrombidiagonal<Precision>(a,
m, n, isupper,
w, e);
648 if( additionalmemory<2 || uneeded==0 )
654 result = bdsvd::bidiagonalsvddecomposition<Precision>(
w, e, minmn, isupper,
false, u, nru, a, 0, vt, ncvt);
663 blas::copyandtranspose<Precision>(u, 1,
m, 1, minmn, t2, 1, minmn, 1,
m);
664 result = bdsvd::bidiagonalsvddecomposition<Precision>(
w, e, minmn, isupper,
false, u, 0, t2,
m, vt, ncvt);
665 blas::copyandtranspose<Precision>(t2, 1, minmn, 1,
m, u, 1,
m, 1, minmn);
void tau(int **points, int sizePoints, int k)
static void make_assertion(bool bClause)
void setbounds(int iLow, int iHigh)
void setbounds(int iLow1, int iHigh1, int iLow2, int iHigh2)
int maxint(int m1, int m2)
int minint(int m1, int m2)
bool rmatrixsvd(ap::template_2d_array< amp::ampf< Precision > > a, int m, int n, int uneeded, int vtneeded, int additionalmemory, ap::template_1d_array< amp::ampf< Precision > > &w, ap::template_2d_array< amp::ampf< Precision > > &u, ap::template_2d_array< amp::ampf< Precision > > &vt)
bool svddecomposition(ap::template_2d_array< amp::ampf< Precision > > a, int m, int n, int uneeded, int vtneeded, int additionalmemory, ap::template_1d_array< amp::ampf< Precision > > &w, ap::template_2d_array< amp::ampf< Precision > > &u, ap::template_2d_array< amp::ampf< Precision > > &vt)