LQ decomposition of a rectangular matrix of size MxN Input parameters: A - matrix A whose indexes range within [0..M-1, 0..N-1]. M - number of rows in matrix A. N - number of columns in matrix A. Output parameters: A - matrices L and Q in compact form (see below) Tau - array of scalar factors which are used to form matrix Q. Array whose index ran
| 243 | Bochkanov Sergey |
| 244 | *************************************************************************/ |
| 245 | void rmatrixlq(ap::real_2d_array& a, int m, int n, ap::real_1d_array& tau) |
| 246 | { |
| 247 | ap::real_1d_array work; |
| 248 | ap::real_1d_array t; |
| 249 | ap::real_1d_array taubuf; |
| 250 | int minmn; |
| 251 | ap::real_2d_array tmpa; |
| 252 | ap::real_2d_array tmpt; |
| 253 | ap::real_2d_array tmpr; |
| 254 | int blockstart; |
| 255 | int blocksize; |
| 256 | int columnscount; |
| 257 | int i; |
| 258 | // int j; |
| 259 | // int k; |
| 260 | // double v; |
| 261 | |
| 262 | if( m<=0||n<=0 ) |
| 263 | { |
| 264 | return; |
| 265 | } |
| 266 | minmn = ap::minint(m, n); |
| 267 | work.setlength(ap::maxint(m, n)+1); |
| 268 | t.setlength(ap::maxint(m, n)+1); |
| 269 | tau.setlength(minmn); |
| 270 | taubuf.setlength(minmn); |
| 271 | tmpa.setlength(ablasblocksize(a), n); |
| 272 | tmpt.setlength(ablasblocksize(a), 2*ablasblocksize(a)); |
| 273 | tmpr.setlength(m, 2*ablasblocksize(a)); |
| 274 | |
| 275 | // |
| 276 | // Blocked code |
| 277 | // |
| 278 | blockstart = 0; |
| 279 | while(blockstart!=minmn) |
| 280 | { |
| 281 | |
| 282 | // |
| 283 | // Determine block size |
| 284 | // |
| 285 | blocksize = minmn-blockstart; |
| 286 | if( blocksize>ablasblocksize(a) ) |
| 287 | { |
| 288 | blocksize = ablasblocksize(a); |
| 289 | } |
| 290 | columnscount = n-blockstart; |
| 291 | |
| 292 | // |
| 293 | // LQ decomposition of submatrix. |
| 294 | // Matrix is copied to temporary storage to solve |
| 295 | // some TLB issues arising from non-contiguous memory |
| 296 | // access pattern. |
| 297 | // |
| 298 | rmatrixcopy(blocksize, columnscount, a, blockstart, blockstart, tmpa, 0, 0); |
| 299 | rmatrixlqbasecase(tmpa, blocksize, columnscount, work, t, taubuf); |
| 300 | rmatrixcopy(blocksize, columnscount, tmpa, 0, 0, a, blockstart, blockstart); |
| 301 | ap::vmove(&tau(blockstart), 1, &taubuf(0), 1, ap::vlen(blockstart,blockstart+blocksize-1)); |
| 302 |
no test coverage detected