28 #ifndef DOXYGEN_SHOULD_SKIP_THIS
29 static double mdone = -1.0;
30 static double done = 1.0;
31 static double dzero = 0.0;
113 int SEED[4] = {26, 67, 52, 197};
120 pastix_int_t size_B, size_O, size_W, size_Y, size_A, size_T, sublw;
124 double tolB = sqrt( (
double)(bp) ) * tol;
125 double *AP, *Y, *WT, *T, *B, *tau_b, *omega, *subw;
127 minMN = pastix_imin(m, n);
131 maxrank = pastix_imin( maxrank, minMN );
138 size_W = n * maxrank;
144 sublw = n * bp + pastix_imax( bp, n );
145 sublw = pastix_imax( sublw, size_O );
146 sublw = pastix_imax( sublw, b * maxrank );
148 lwkopt = size_A + size_Y + size_W
149 + size_T + size_B + n + sublw;
152 work[0] = (double)lwkopt;
162 if (lda < pastix_imax(1, m)) {
165 if( lwork < lwkopt ) {
175 if ( maxrank == 0 ) {
180 norm = LAPACKE_dlange_work( LAPACK_COL_MAJOR,
'f', m, n,
200 ret = LAPACKE_dlaset_work( LAPACK_COL_MAJOR,
'A', b, b,
205 memset(T, 0, size_T *
sizeof(
double));
208 ret = LAPACKE_dlacpy_work( LAPACK_COL_MAJOR,
'A', m, n,
213 for (j=0; j<n; j++) jpvt[j] = j;
218 ret = LAPACKE_dlarnv_work(3, SEED, size_O, omega);
220 cblas_dgemm( CblasColMajor, CblasNoTrans, CblasNoTrans,
230 ib = pastix_imin( b, minMN-rk );
235 subw, sublw, rwork );
249 if ( (rk + d) > maxrank ) {
255 for (j = rk; j < rk + d; j++) {
256 if (jpvt_b[j] >= 0) {
261 jpvt_b[k] = - jpvt_b[k] - 1;
263 while( jpvt_b[in] >= 0 ) {
266 cblas_dswap( m, A + k * lda, 1,
268 cblas_dswap( m, AP + k * m, 1,
276 cblas_dswap( rk, WT + k * ldw, 1,
281 jpvt_b[in] = - jpvt_b[in] - 1;
290 cblas_dgemm( CblasColMajor, CblasNoTrans, CblasNoTrans,
292 (mdone), A + rk, lda,
294 (done), A + rk * lda + rk, lda );
300 ret = LAPACKE_dgeqrf_work( LAPACK_COL_MAJOR, m-rk, d,
301 A + rk * lda + rk, lda, tau + rk,
305 ret = LAPACKE_dlarft_work( LAPACK_COL_MAJOR,
'F',
'C', m-rk, d,
306 A + rk * lda + rk, lda, tau + rk, T, b );
319 ret = LAPACKE_dlacpy_work( LAPACK_COL_MAJOR,
'L', d-1, d-1,
320 A + lda * rk + rk + 1, lda,
325 cblas_dgemm( CblasColMajor, CblasTrans, CblasNoTrans,
329 (dzero), WT + rk, ldw );
333 cblas_dgemm( CblasColMajor, CblasTrans, CblasNoTrans,
335 (done), A + rk * lda + rk + d, lda,
337 (done), WT + rk, ldw );
347 cblas_dgemm( CblasColMajor, CblasTrans, CblasNoTrans,
355 cblas_dgemm( CblasColMajor, CblasTrans, CblasNoTrans,
357 (done), A + rk * lda + rk + d, lda,
362 cblas_dgemm( CblasColMajor, CblasNoTrans, CblasNoTrans,
366 (done), WT + rk, ldw );
373 cblas_dtrmm( CblasColMajor, CblasLeft, CblasUpper, CblasTrans, CblasNonUnit,
380 cblas_dgemm( CblasColMajor, CblasNoTrans, CblasNoTrans,
382 (mdone), A + rk, lda,
383 WT + (rk+d)*ldw, ldw,
384 (done), A + rk + (rk+d)*lda, lda );
386 cblas_dgemm( CblasColMajor, CblasNoTrans, CblasNoTrans,
389 WT + rk + (rk+d)*ldw, ldw,
390 (done), A + rk + (rk+d)*lda, lda );
393 if ( loop && (rk+d < maxrank) ) {
398 ret = LAPACKE_dlaset_work( LAPACK_COL_MAJOR,
'L', d-1, d-1,
399 0, 0, B + rk*ldb + 1, ldb );
404 cblas_dtrsm( CblasColMajor, CblasRight, CblasUpper,
405 CblasNoTrans, CblasNonUnit,
407 (done), A + rk*lda + rk, lda,
411 cblas_dgemm( CblasColMajor, CblasNoTrans, CblasNoTrans,
413 (mdone), B + rk *ldb, ldb,
414 A + (rk+d)*lda + rk, lda,
415 (done), B + (rk+d)*ldb, ldb );
537 const void *alphaptr,
548 M1, N1, A, M2, N2, B, offx, offy );
Manage nancheck for lowrank kernels. This header describes all the LAPACKE functions used for low-ran...
BEGIN_C_DECLS typedef int pastix_int_t
int core_dtqrcp(double tol, pastix_int_t maxrank, int refine, pastix_int_t nb, pastix_int_t m, pastix_int_t n, double *A, pastix_int_t lda, pastix_int_t *jpvt, double *tau, double *work, pastix_int_t lwork, double *rwork)
Compute a randomized QR factorization with truncated updates.
int core_dpqrcp(double tol, pastix_int_t maxrank, int full_update, pastix_int_t nb, pastix_int_t m, pastix_int_t n, double *A, pastix_int_t lda, pastix_int_t *jpvt, double *tau, double *work, pastix_int_t lwork, double *rwork)
Compute a rank-reavealing QR factorization.
Structure to define the type of function to use for the low-rank kernels and their parameters.
The block low-rank structure to hold a matrix in low-rank form.
pastix_fixdbl_t core_dge2lr_qrcp(core_drrqr_cp_t rrqrfct, int use_reltol, pastix_fixdbl_t tol, pastix_int_t rklimit, pastix_int_t m, pastix_int_t n, const void *Avoid, pastix_int_t lda, pastix_lrblock_t *Alr)
Template to convert a full rank matrix into a low rank matrix through QR decompositions.
pastix_fixdbl_t core_drradd_tqrcp(const pastix_lr_t *lowrank, pastix_trans_t transA1, const void *alphaptr, pastix_int_t M1, pastix_int_t N1, const pastix_lrblock_t *A, pastix_int_t M2, pastix_int_t N2, pastix_lrblock_t *B, pastix_int_t offx, pastix_int_t offy)
Add two LR structures A=(-u1) v1^T and B=u2 v2^T into u2 v2^T.
pastix_fixdbl_t core_drradd_qr(core_drrqr_cp_t rrqrfct, const pastix_lr_t *lowrank, pastix_trans_t transA1, const void *alphaptr, pastix_int_t M1, pastix_int_t N1, const pastix_lrblock_t *A, pastix_int_t M2, pastix_int_t N2, pastix_lrblock_t *B, pastix_int_t offx, pastix_int_t offy)
Template to perform the addition of two low-rank structures with compression kernel based on QR decom...
pastix_fixdbl_t core_dge2lr_tqrcp(int use_reltol, pastix_fixdbl_t tol, pastix_int_t rklimit, pastix_int_t m, pastix_int_t n, const void *A, pastix_int_t lda, pastix_lrblock_t *Alr)
Convert a full rank matrix in a low rank matrix, using TQRCP.
enum pastix_trans_e pastix_trans_t
Transpostion.