MCPcopy Create free account
hub / github.com/BoevaLab/FREEC / rmatrixbd

Function rmatrixbd

src/ortfac.cpp:1413–1540  ·  view source on GitHub ↗

Reduction of a rectangular matrix to bidiagonal form The algorithm reduces the rectangular matrix A to bidiagonal form by orthogonal transformations P and Q: A = Q*B*P. Input parameters: A - source matrix. array[0..M-1, 0..N-1] M - number of rows in matrix A. N - number of columns in matrix A. Output parameters: A - matrices Q, B, P in compact f

Source from the content-addressed store, hash-verified

1411 pseudocode, 2007-2010.
1412*************************************************************************/
1413void rmatrixbd(ap::real_2d_array& a,
1414 int m,
1415 int n,
1416 ap::real_1d_array& tauq,
1417 ap::real_1d_array& taup)
1418{
1419 ap::real_1d_array work;
1420 ap::real_1d_array t;
1421 int minmn;
1422 int maxmn;
1423 int i;
1424 double ltau;
1425
1426
1427 //
1428 // Prepare
1429 //
1430 if( n<=0||m<=0 )
1431 {
1432 return;
1433 }
1434 minmn = ap::minint(m, n);
1435 maxmn = ap::maxint(m, n);
1436 work.setlength(maxmn+1);
1437 t.setlength(maxmn+1);
1438 if( m>=n )
1439 {
1440 tauq.setlength(n);
1441 taup.setlength(n);
1442 }
1443 else
1444 {
1445 tauq.setlength(m);
1446 taup.setlength(m);
1447 }
1448 if( m>=n )
1449 {
1450
1451 //
1452 // Reduce to upper bidiagonal form
1453 //
1454 for(i = 0; i <= n-1; i++)
1455 {
1456
1457 //
1458 // Generate elementary reflector H(i) to annihilate A(i+1:m-1,i)
1459 //
1460 ap::vmove(&t(1), 1, &a(i, i), a.getstride(), ap::vlen(1,m-i));
1461 generatereflection(t, m-i, ltau);
1462 tauq(i) = ltau;
1463 ap::vmove(&a(i, i), a.getstride(), &t(1), 1, ap::vlen(i,m-1));
1464 t(1) = 1;
1465
1466 //
1467 // Apply H(i) to A(i:m-1,i+1:n-1) from the left
1468 //
1469 applyreflectionfromtheleft(a, ltau, t, i, m-1, i+1, n-1, work);
1470 if( i<n-1 )

Callers 1

rmatrixsvdFunction · 0.85

Calls 6

vmoveFunction · 0.85
generatereflectionFunction · 0.85
getstrideMethod · 0.80
setlengthMethod · 0.45

Tested by

no test coverage detected