lapack_int LAPACKE_dgeesx( int matrix_order, char jobvs, char sort, LAPACK_D_SELECT2 select, char sense, lapack_int n, double* a, lapack_int lda, lapack_int* sdim, double* wr, double* wi, double* vs, lapack_int ldvs, double* rconde, double* rcondv ) { lapack_int info = 0; lapack_int liwork = -1; lapack_int lwork = -1; lapack_logical* bwork = NULL; lapack_int* iwork = NULL; double* work = NULL; lapack_int iwork_query; double work_query; if( matrix_order != LAPACK_COL_MAJOR && matrix_order != LAPACK_ROW_MAJOR ) { LAPACKE_xerbla( "LAPACKE_dgeesx", -1 ); return -1; } #ifndef LAPACK_DISABLE_NAN_CHECK /* Optionally check input matrices for NaNs */ if( LAPACKE_dge_nancheck( matrix_order, n, n, a, lda ) ) { return -7; } #endif /* Allocate memory for working array(s) */ if( LAPACKE_lsame( sort, 's' ) ) { bwork = (lapack_logical*) LAPACKE_malloc( sizeof(lapack_logical) * MAX(1,n) ); if( bwork == NULL ) { info = LAPACK_WORK_MEMORY_ERROR; goto exit_level_0; } } /* Query optimal working array(s) size */ info = LAPACKE_dgeesx_work( matrix_order, jobvs, sort, select, sense, n, a, lda, sdim, wr, wi, vs, ldvs, rconde, rcondv, &work_query, lwork, &iwork_query, liwork, bwork ); if( info != 0 ) { goto exit_level_1; } liwork = (lapack_int)iwork_query; lwork = (lapack_int)work_query; /* Allocate memory for work arrays */ if( LAPACKE_lsame( sense, 'b' ) || LAPACKE_lsame( sense, 'v' ) ) { iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork ); if( iwork == NULL ) { info = LAPACK_WORK_MEMORY_ERROR; goto exit_level_1; } } work = (double*)LAPACKE_malloc( sizeof(double) * lwork ); if( work == NULL ) { info = LAPACK_WORK_MEMORY_ERROR; goto exit_level_2; } /* Call middle-level interface */ info = LAPACKE_dgeesx_work( matrix_order, jobvs, sort, select, sense, n, a, lda, sdim, wr, wi, vs, ldvs, rconde, rcondv, work, lwork, iwork, liwork, bwork ); /* Release memory and exit */ LAPACKE_free( work ); exit_level_2: if( LAPACKE_lsame( sense, 'b' ) || LAPACKE_lsame( sense, 'v' ) ) { LAPACKE_free( iwork ); } exit_level_1: if( LAPACKE_lsame( sort, 's' ) ) { LAPACKE_free( bwork ); } exit_level_0: if( info == LAPACK_WORK_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_dgeesx", info ); } return info; }
lapack_int LAPACKE_ssbevx_work( int matrix_order, char jobz, char range, char uplo, lapack_int n, lapack_int kd, float* ab, lapack_int ldab, float* q, lapack_int ldq, float vl, float vu, lapack_int il, lapack_int iu, float abstol, lapack_int* m, float* w, float* z, lapack_int ldz, float* work, lapack_int* iwork, lapack_int* ifail ) { lapack_int info = 0; if( matrix_order == LAPACK_COL_MAJOR ) { /* Call LAPACK function and adjust info */ LAPACK_ssbevx( &jobz, &range, &uplo, &n, &kd, ab, &ldab, q, &ldq, &vl, &vu, &il, &iu, &abstol, m, w, z, &ldz, work, iwork, ifail, &info ); if( info < 0 ) { info = info - 1; } } else if( matrix_order == LAPACK_ROW_MAJOR ) { lapack_int ncols_z = ( LAPACKE_lsame( range, 'a' ) || LAPACKE_lsame( range, 'v' ) ) ? n : ( LAPACKE_lsame( range, 'i' ) ? (iu-il+1) : 1); lapack_int ldab_t = MAX(1,kd+1); lapack_int ldq_t = MAX(1,n); lapack_int ldz_t = MAX(1,n); float* ab_t = NULL; float* q_t = NULL; float* z_t = NULL; /* Check leading dimension(s) */ if( ldab < n ) { info = -8; LAPACKE_xerbla( "LAPACKE_ssbevx_work", info ); return info; } if( ldq < n ) { info = -10; LAPACKE_xerbla( "LAPACKE_ssbevx_work", info ); return info; } if( ldz < ncols_z ) { info = -19; LAPACKE_xerbla( "LAPACKE_ssbevx_work", info ); return info; } /* Allocate memory for temporary array(s) */ ab_t = (float*)LAPACKE_malloc( sizeof(float) * ldab_t * MAX(1,n) ); if( ab_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_0; } if( LAPACKE_lsame( jobz, 'v' ) ) { q_t = (float*)LAPACKE_malloc( sizeof(float) * ldq_t * MAX(1,n) ); if( q_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_1; } } if( LAPACKE_lsame( jobz, 'v' ) ) { z_t = (float*) LAPACKE_malloc( sizeof(float) * ldz_t * MAX(1,ncols_z) ); if( z_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_2; } } /* Transpose input matrices */ LAPACKE_ssb_trans( matrix_order, uplo, n, kd, ab, ldab, ab_t, ldab_t ); /* Call LAPACK function and adjust info */ LAPACK_ssbevx( &jobz, &range, &uplo, &n, &kd, ab_t, &ldab_t, q_t, &ldq_t, &vl, &vu, &il, &iu, &abstol, m, w, z_t, &ldz_t, work, iwork, ifail, &info ); if( info < 0 ) { info = info - 1; } /* Transpose output matrices */ LAPACKE_ssb_trans( LAPACK_COL_MAJOR, uplo, n, kd, ab_t, ldab_t, ab, ldab ); if( LAPACKE_lsame( jobz, 'v' ) ) { LAPACKE_sge_trans( LAPACK_COL_MAJOR, n, n, q_t, ldq_t, q, ldq ); } if( LAPACKE_lsame( jobz, 'v' ) ) { LAPACKE_sge_trans( LAPACK_COL_MAJOR, n, ncols_z, z_t, ldz_t, z, ldz ); } /* Release memory and exit */ if( LAPACKE_lsame( jobz, 'v' ) ) { LAPACKE_free( z_t ); } exit_level_2: if( LAPACKE_lsame( jobz, 'v' ) ) { LAPACKE_free( q_t ); } exit_level_1: LAPACKE_free( ab_t ); exit_level_0: if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_ssbevx_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_ssbevx_work", info ); } return info; }
lapack_int LAPACKE_dgges( int matrix_layout, char jobvsl, char jobvsr, char sort, LAPACK_D_SELECT3 selctg, lapack_int n, double* a, lapack_int lda, double* b, lapack_int ldb, lapack_int* sdim, double* alphar, double* alphai, double* beta, double* vsl, lapack_int ldvsl, double* vsr, lapack_int ldvsr ) { lapack_int info = 0; lapack_int lwork = -1; lapack_logical* bwork = NULL; double* work = NULL; double work_query; if( matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR ) { LAPACKE_xerbla( "LAPACKE_dgges", -1 ); return -1; } #ifndef LAPACK_DISABLE_NAN_CHECK /* Optionally check input matrices for NaNs */ if( LAPACKE_dge_nancheck( matrix_layout, n, n, a, lda ) ) { return -7; } if( LAPACKE_dge_nancheck( matrix_layout, n, n, b, ldb ) ) { return -9; } #endif /* Allocate memory for working array(s) */ if( LAPACKE_lsame( sort, 's' ) ) { bwork = (lapack_logical*) LAPACKE_malloc( sizeof(lapack_logical) * MAX(1,n) ); if( bwork == NULL ) { info = LAPACK_WORK_MEMORY_ERROR; goto exit_level_0; } } /* Query optimal working array(s) size */ info = LAPACKE_dgges_work( matrix_layout, jobvsl, jobvsr, sort, selctg, n, a, lda, b, ldb, sdim, alphar, alphai, beta, vsl, ldvsl, vsr, ldvsr, &work_query, lwork, bwork ); if( info != 0 ) { goto exit_level_1; } lwork = (lapack_int)work_query; /* Allocate memory for work arrays */ work = (double*)LAPACKE_malloc( sizeof(double) * lwork ); if( work == NULL ) { info = LAPACK_WORK_MEMORY_ERROR; goto exit_level_1; } /* Call middle-level interface */ info = LAPACKE_dgges_work( matrix_layout, jobvsl, jobvsr, sort, selctg, n, a, lda, b, ldb, sdim, alphar, alphai, beta, vsl, ldvsl, vsr, ldvsr, work, lwork, bwork ); /* Release memory and exit */ LAPACKE_free( work ); exit_level_1: if( LAPACKE_lsame( sort, 's' ) ) { LAPACKE_free( bwork ); } exit_level_0: if( info == LAPACK_WORK_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_dgges", info ); } return info; }
lapack_int LAPACKE_dgbsvx( int matrix_order, char fact, char trans, lapack_int n, lapack_int kl, lapack_int ku, lapack_int nrhs, double* ab, lapack_int ldab, double* afb, lapack_int ldafb, lapack_int* ipiv, char* equed, double* r, double* c, double* b, lapack_int ldb, double* x, lapack_int ldx, double* rcond, double* ferr, double* berr, double* rpivot ) { lapack_int info = 0; lapack_int* iwork = NULL; double* work = NULL; if( matrix_order != LAPACK_COL_MAJOR && matrix_order != LAPACK_ROW_MAJOR ) { LAPACKE_xerbla( "LAPACKE_dgbsvx", -1 ); return -1; } #ifndef LAPACK_DISABLE_NAN_CHECK /* Optionally check input matrices for NaNs */ if( LAPACKE_dgb_nancheck( matrix_order, n, n, kl, ku, ab, ldab ) ) { return -8; } if( LAPACKE_lsame( fact, 'f' ) ) { if( LAPACKE_dgb_nancheck( matrix_order, n, n, kl, kl+ku, afb, ldafb ) ) { return -10; } } if( LAPACKE_dge_nancheck( matrix_order, n, nrhs, b, ldb ) ) { return -16; } if( LAPACKE_lsame( fact, 'f' ) && ( LAPACKE_lsame( *equed, 'b' ) || LAPACKE_lsame( *equed, 'c' ) ) ) { if( LAPACKE_d_nancheck( n, c, 1 ) ) { return -15; } } if( LAPACKE_lsame( fact, 'f' ) && ( LAPACKE_lsame( *equed, 'b' ) || LAPACKE_lsame( *equed, 'r' ) ) ) { if( LAPACKE_d_nancheck( n, r, 1 ) ) { return -14; } } #endif /* Allocate memory for working array(s) */ iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * MAX(1,n) ); if( iwork == NULL ) { info = LAPACK_WORK_MEMORY_ERROR; goto exit_level_0; } work = (double*)LAPACKE_malloc( sizeof(double) * MAX(1,3*n) ); if( work == NULL ) { info = LAPACK_WORK_MEMORY_ERROR; goto exit_level_1; } /* Call middle-level interface */ info = LAPACKE_dgbsvx_work( matrix_order, fact, trans, n, kl, ku, nrhs, ab, ldab, afb, ldafb, ipiv, equed, r, c, b, ldb, x, ldx, rcond, ferr, berr, work, iwork ); /* Backup significant data from working array(s) */ *rpivot = work[0]; /* Release memory and exit */ LAPACKE_free( work ); exit_level_1: LAPACKE_free( iwork ); exit_level_0: if( info == LAPACK_WORK_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_dgbsvx", info ); } return info; }
lapack_int LAPACKE_dgbsvxx( int matrix_layout, char fact, char trans, lapack_int n, lapack_int kl, lapack_int ku, lapack_int nrhs, double* ab, lapack_int ldab, double* afb, lapack_int ldafb, lapack_int* ipiv, char* equed, double* r, double* c, double* b, lapack_int ldb, double* x, lapack_int ldx, double* rcond, double* rpvgrw, double* berr, lapack_int n_err_bnds, double* err_bnds_norm, double* err_bnds_comp, lapack_int nparams, double* params ) { lapack_int info = 0; lapack_int* iwork = NULL; double* work = NULL; if( matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR ) { LAPACKE_xerbla( "LAPACKE_dgbsvxx", -1 ); return -1; } #ifndef LAPACK_DISABLE_NAN_CHECK if( LAPACKE_get_nancheck() ) { /* Optionally check input matrices for NaNs */ if( LAPACKE_dgb_nancheck( matrix_layout, n, n, kl, ku, ab, ldab ) ) { return -8; } if( LAPACKE_lsame( fact, 'f' ) ) { if( LAPACKE_dgb_nancheck( matrix_layout, n, n, kl, kl+ku, afb, ldafb ) ) { return -10; } } if( LAPACKE_dge_nancheck( matrix_layout, n, nrhs, b, ldb ) ) { return -16; } if( LAPACKE_lsame( fact, 'f' ) && ( LAPACKE_lsame( *equed, 'b' ) || LAPACKE_lsame( *equed, 'c' ) ) ) { if( LAPACKE_d_nancheck( n, c, 1 ) ) { return -15; } } if( nparams>0 ) { if( LAPACKE_d_nancheck( nparams, params, 1 ) ) { return -27; } } if( LAPACKE_lsame( fact, 'f' ) && ( LAPACKE_lsame( *equed, 'b' ) || LAPACKE_lsame( *equed, 'r' ) ) ) { if( LAPACKE_d_nancheck( n, r, 1 ) ) { return -14; } } } #endif /* Allocate memory for working array(s) */ iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * MAX(1,n) ); if( iwork == NULL ) { info = LAPACK_WORK_MEMORY_ERROR; goto exit_level_0; } work = (double*)LAPACKE_malloc( sizeof(double) * MAX(1,4*n) ); if( work == NULL ) { info = LAPACK_WORK_MEMORY_ERROR; goto exit_level_1; } /* Call middle-level interface */ info = LAPACKE_dgbsvxx_work( matrix_layout, fact, trans, n, kl, ku, nrhs, ab, ldab, afb, ldafb, ipiv, equed, r, c, b, ldb, x, ldx, rcond, rpvgrw, berr, n_err_bnds, err_bnds_norm, err_bnds_comp, nparams, params, work, iwork ); /* Release memory and exit */ LAPACKE_free( work ); exit_level_1: LAPACKE_free( iwork ); exit_level_0: if( info == LAPACK_WORK_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_dgbsvxx", info ); } return info; }
lapack_int LAPACKE_dtprfb_work( int matrix_order, char side, char trans, char direct, char storev, lapack_int m, lapack_int n, lapack_int k, lapack_int l, const double* v, lapack_int ldv, const double* t, lapack_int ldt, double* a, lapack_int lda, double* b, lapack_int ldb, const double* work, lapack_int ldwork ) { lapack_int info = 0; if( matrix_order == LAPACK_COL_MAJOR ) { /* Call LAPACK function and adjust info */ LAPACK_dtprfb( &side, &trans, &direct, &storev, &m, &n, &k, &l, v, &ldv, t, &ldt, a, &lda, b, &ldb, work, &ldwork ); if( info < 0 ) { info = info - 1; } } else if( matrix_order == LAPACK_ROW_MAJOR ) { lapack_int r = LAPACKE_lsame( side, 'r' ) ? k : k; lapack_int lda_t = MAX(1,k); lapack_int ldb_t = MAX(1,m); lapack_int ldt_t = MAX(1,ldt); lapack_int ldv_t = MAX(1,ldv); double* v_t = NULL; double* t_t = NULL; double* a_t = NULL; double* b_t = NULL; /* Check leading dimension(s) */ if( lda < m ) { info = -15; LAPACKE_xerbla( "LAPACKE_dtprfb_work", info ); return info; } if( ldb < n ) { info = -17; LAPACKE_xerbla( "LAPACKE_dtprfb_work", info ); return info; } if( ldt < k ) { info = -13; LAPACKE_xerbla( "LAPACKE_dtprfb_work", info ); return info; } if( ldv < k ) { info = -11; LAPACKE_xerbla( "LAPACKE_dtprfb_work", info ); return info; } /* Allocate memory for temporary array(s) */ v_t = (double*)LAPACKE_malloc( sizeof(double) * ldv_t * MAX(1,k) ); if( v_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_0; } t_t = (double*)LAPACKE_malloc( sizeof(double) * ldt_t * MAX(1,k) ); if( t_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_1; } a_t = (double*)LAPACKE_malloc( sizeof(double) * lda_t * MAX(1,m) ); if( a_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_2; } b_t = (double*)LAPACKE_malloc( sizeof(double) * ldb_t * MAX(1,n) ); if( b_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_3; } /* Transpose input matrices */ LAPACKE_dge_trans( matrix_order, ldv, k, v, ldv, v_t, ldv_t ); LAPACKE_dge_trans( matrix_order, ldt, k, t, ldt, t_t, ldt_t ); LAPACKE_dge_trans( matrix_order, k, m, a, lda, a_t, lda_t ); LAPACKE_dge_trans( matrix_order, m, n, b, ldb, b_t, ldb_t ); /* Call LAPACK function and adjust info */ LAPACK_dtprfb( &side, &trans, &direct, &storev, &m, &n, &k, &l, v_t, &ldv_t, t_t, &ldt_t, a_t, &lda_t, b_t, &ldb_t, work, &ldwork ); info = 0; /* LAPACK call is ok! */ /* Transpose output matrices */ LAPACKE_dge_trans( LAPACK_COL_MAJOR, k, m, a_t, lda_t, a, lda ); LAPACKE_dge_trans( LAPACK_COL_MAJOR, m, n, b_t, ldb_t, b, ldb ); /* Release memory and exit */ LAPACKE_free( b_t ); exit_level_3: LAPACKE_free( a_t ); exit_level_2: LAPACKE_free( t_t ); exit_level_1: LAPACKE_free( v_t ); exit_level_0: if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_dtprfb_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_dtprfb_work", info ); } return info; }
lapack_int LAPACKE_ssyevr( int matrix_layout, char jobz, char range, char uplo, lapack_int n, float* a, lapack_int lda, float vl, float vu, lapack_int il, lapack_int iu, float abstol, lapack_int* m, float* w, float* z, lapack_int ldz, lapack_int* isuppz ) { lapack_int info = 0; lapack_int liwork = -1; lapack_int lwork = -1; lapack_int* iwork = NULL; float* work = NULL; lapack_int iwork_query; float work_query; if( matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR ) { LAPACKE_xerbla( "LAPACKE_ssyevr", -1 ); return -1; } #ifndef LAPACK_DISABLE_NAN_CHECK if( LAPACKE_get_nancheck() ) { /* Optionally check input matrices for NaNs */ if( LAPACKE_ssy_nancheck( matrix_layout, uplo, n, a, lda ) ) { return -6; } if( LAPACKE_s_nancheck( 1, &abstol, 1 ) ) { return -12; } if( LAPACKE_lsame( range, 'v' ) ) { if( LAPACKE_s_nancheck( 1, &vl, 1 ) ) { return -8; } } if( LAPACKE_lsame( range, 'v' ) ) { if( LAPACKE_s_nancheck( 1, &vu, 1 ) ) { return -9; } } } #endif /* Query optimal working array(s) size */ info = LAPACKE_ssyevr_work( matrix_layout, jobz, range, uplo, n, a, lda, vl, vu, il, iu, abstol, m, w, z, ldz, isuppz, &work_query, lwork, &iwork_query, liwork ); if( info != 0 ) { goto exit_level_0; } liwork = (lapack_int)iwork_query; lwork = (lapack_int)work_query; /* Allocate memory for work arrays */ iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork ); if( iwork == NULL ) { info = LAPACK_WORK_MEMORY_ERROR; goto exit_level_0; } work = (float*)LAPACKE_malloc( sizeof(float) * lwork ); if( work == NULL ) { info = LAPACK_WORK_MEMORY_ERROR; goto exit_level_1; } /* Call middle-level interface */ info = LAPACKE_ssyevr_work( matrix_layout, jobz, range, uplo, n, a, lda, vl, vu, il, iu, abstol, m, w, z, ldz, isuppz, work, lwork, iwork, liwork ); /* Release memory and exit */ LAPACKE_free( work ); exit_level_1: LAPACKE_free( iwork ); exit_level_0: if( info == LAPACK_WORK_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_ssyevr", info ); } return info; }
lapack_int LAPACKE_cheevx( int matrix_order, char jobz, char range, char uplo, lapack_int n, lapack_complex_float* a, lapack_int lda, float vl, float vu, lapack_int il, lapack_int iu, float abstol, lapack_int* m, float* w, lapack_complex_float* z, lapack_int ldz, lapack_int* ifail ) { lapack_int info = 0; lapack_int lwork = -1; lapack_int* iwork = NULL; float* rwork = NULL; lapack_complex_float* work = NULL; lapack_complex_float work_query; if( matrix_order != LAPACK_COL_MAJOR && matrix_order != LAPACK_ROW_MAJOR ) { LAPACKE_xerbla( "LAPACKE_cheevx", -1 ); return -1; } #ifndef LAPACK_DISABLE_NAN_CHECK /* Optionally check input matrices for NaNs */ if( LAPACKE_che_nancheck( matrix_order, uplo, n, a, lda ) ) { return -6; } if( LAPACKE_s_nancheck( 1, &abstol, 1 ) ) { return -12; } if( LAPACKE_lsame( range, 'v' ) ) { if( LAPACKE_s_nancheck( 1, &vl, 1 ) ) { return -8; } } if( LAPACKE_lsame( range, 'v' ) ) { if( LAPACKE_s_nancheck( 1, &vu, 1 ) ) { return -9; } } #endif /* Allocate memory for working array(s) */ iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * MAX(1,5*n) ); if( iwork == NULL ) { info = LAPACK_WORK_MEMORY_ERROR; goto exit_level_0; } rwork = (float*)LAPACKE_malloc( sizeof(float) * MAX(1,7*n) ); if( rwork == NULL ) { info = LAPACK_WORK_MEMORY_ERROR; goto exit_level_1; } /* Query optimal working array(s) size */ info = LAPACKE_cheevx_work( matrix_order, jobz, range, uplo, n, a, lda, vl, vu, il, iu, abstol, m, w, z, ldz, &work_query, lwork, rwork, iwork, ifail ); if( info != 0 ) { goto exit_level_2; } lwork = LAPACK_C2INT( work_query ); /* Allocate memory for work arrays */ work = (lapack_complex_float*) LAPACKE_malloc( sizeof(lapack_complex_float) * lwork ); if( work == NULL ) { info = LAPACK_WORK_MEMORY_ERROR; goto exit_level_2; } /* Call middle-level interface */ info = LAPACKE_cheevx_work( matrix_order, jobz, range, uplo, n, a, lda, vl, vu, il, iu, abstol, m, w, z, ldz, work, lwork, rwork, iwork, ifail ); /* Release memory and exit */ LAPACKE_free( work ); exit_level_2: LAPACKE_free( rwork ); exit_level_1: LAPACKE_free( iwork ); exit_level_0: if( info == LAPACK_WORK_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_cheevx", info ); } return info; }
lapack_int LAPACKE_zgesvj_work( int matrix_layout, char joba, char jobu, char jobv, lapack_int m, lapack_int n, lapack_complex_double* a, lapack_int lda, double* sva, lapack_int mv, lapack_complex_double* v, lapack_int ldv, lapack_complex_double* cwork, lapack_int lwork, double* rwork, lapack_int lrwork ) { lapack_int info = 0; if( matrix_layout == LAPACK_COL_MAJOR ) { /* Call LAPACK function and adjust info */ LAPACK_zgesvj( &joba, &jobu, &jobv, &m, &n, a, &lda, sva, &mv, v, &ldv, cwork, &lwork, rwork, &lrwork, &info ); if( info < 0 ) { info = info - 1; } } else if( matrix_layout == LAPACK_ROW_MAJOR ) { lapack_int nrows_v = LAPACKE_lsame( jobv, 'v' ) ? MAX(0,n) : ( LAPACKE_lsame( jobv, 'a' ) ? MAX(0,mv) : 0); lapack_int lda_t = MAX(1,m); lapack_int ldv_t = MAX(1,nrows_v); lapack_complex_double* a_t = NULL; lapack_complex_double* v_t = NULL; /* Check leading dimension(s) */ if( lda < n ) { info = -8; LAPACKE_xerbla( "LAPACKE_zgesvj_work", info ); return info; } if( ldv < n ) { info = -12; LAPACKE_xerbla( "LAPACKE_zgesvj_work", info ); return info; } /* Allocate memory for temporary array(s) */ a_t = (lapack_complex_double*) LAPACKE_malloc( sizeof(lapack_complex_double) * lda_t * MAX(1,n) ); if( a_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_0; } if( LAPACKE_lsame( jobv, 'a' ) || LAPACKE_lsame( jobv, 'v' ) ) { v_t = (lapack_complex_double*) LAPACKE_malloc( sizeof(lapack_complex_double) * ldv_t * MAX(1,n) ); if( v_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_1; } } /* Transpose input matrices */ LAPACKE_zge_trans( matrix_layout, m, n, a, lda, a_t, lda_t ); if( LAPACKE_lsame( jobv, 'a' ) ) { LAPACKE_zge_trans( matrix_layout, nrows_v, n, v, ldv, v_t, ldv_t ); } /* Call LAPACK function and adjust info */ LAPACK_zgesvj( &joba, &jobu, &jobv, &m, &n, a_t, &lda_t, sva, &mv, v_t, &ldv_t, cwork, &lwork, rwork, &lrwork, &info ); if( info < 0 ) { info = info - 1; } /* Transpose output matrices */ LAPACKE_zge_trans( LAPACK_COL_MAJOR, m, n, a_t, lda_t, a, lda ); if( LAPACKE_lsame( jobv, 'a' ) || LAPACKE_lsame( jobv, 'v' ) ) { LAPACKE_zge_trans( LAPACK_COL_MAJOR, nrows_v, n, v_t, ldv_t, v, ldv ); } /* Release memory and exit */ if( LAPACKE_lsame( jobv, 'a' ) || LAPACKE_lsame( jobv, 'v' ) ) { LAPACKE_free( v_t ); } exit_level_1: LAPACKE_free( a_t ); exit_level_0: if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_zgesvj_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_zgesvj_work", info ); } return info; }
lapack_int LAPACKE_zsysvxx_work( int matrix_order, char fact, char uplo, lapack_int n, lapack_int nrhs, lapack_complex_double* a, lapack_int lda, lapack_complex_double* af, lapack_int ldaf, lapack_int* ipiv, char* equed, double* s, lapack_complex_double* b, lapack_int ldb, lapack_complex_double* x, lapack_int ldx, double* rcond, double* rpvgrw, double* berr, lapack_int n_err_bnds, double* err_bnds_norm, double* err_bnds_comp, lapack_int nparams, double* params, lapack_complex_double* work, double* rwork ) { lapack_int info = 0; if( matrix_order == LAPACK_COL_MAJOR ) { /* Call LAPACK function and adjust info */ LAPACK_zsysvxx( &fact, &uplo, &n, &nrhs, a, &lda, af, &ldaf, ipiv, equed, s, b, &ldb, x, &ldx, rcond, rpvgrw, berr, &n_err_bnds, err_bnds_norm, err_bnds_comp, &nparams, params, work, rwork, &info ); if( info < 0 ) { info = info - 1; } } else if( matrix_order == LAPACK_ROW_MAJOR ) { lapack_int lda_t = MAX(1,n); lapack_int ldaf_t = MAX(1,n); lapack_int ldb_t = MAX(1,n); lapack_int ldx_t = MAX(1,n); lapack_complex_double* a_t = NULL; lapack_complex_double* af_t = NULL; lapack_complex_double* b_t = NULL; lapack_complex_double* x_t = NULL; double* err_bnds_norm_t = NULL; double* err_bnds_comp_t = NULL; /* Check leading dimension(s) */ if( lda < n ) { info = -7; LAPACKE_xerbla( "LAPACKE_zsysvxx_work", info ); return info; } if( ldaf < n ) { info = -9; LAPACKE_xerbla( "LAPACKE_zsysvxx_work", info ); return info; } if( ldb < nrhs ) { info = -14; LAPACKE_xerbla( "LAPACKE_zsysvxx_work", info ); return info; } if( ldx < nrhs ) { info = -16; LAPACKE_xerbla( "LAPACKE_zsysvxx_work", info ); return info; } /* Allocate memory for temporary array(s) */ a_t = (lapack_complex_double*) LAPACKE_malloc( sizeof(lapack_complex_double) * lda_t * MAX(1,n) ); if( a_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_0; } af_t = (lapack_complex_double*) LAPACKE_malloc( sizeof(lapack_complex_double) * ldaf_t * MAX(1,n) ); if( af_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_1; } b_t = (lapack_complex_double*) LAPACKE_malloc( sizeof(lapack_complex_double) * ldb_t * MAX(1,nrhs) ); if( b_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_2; } x_t = (lapack_complex_double*) LAPACKE_malloc( sizeof(lapack_complex_double) * ldx_t * MAX(1,nrhs) ); if( x_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_3; } err_bnds_norm_t = (double*) LAPACKE_malloc( sizeof(double) * nrhs * MAX(1,n_err_bnds) ); if( err_bnds_norm_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_4; } err_bnds_comp_t = (double*) LAPACKE_malloc( sizeof(double) * nrhs * MAX(1,n_err_bnds) ); if( err_bnds_comp_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_5; } /* Transpose input matrices */ LAPACKE_zsy_trans( matrix_order, uplo, n, a, lda, a_t, lda_t ); if( LAPACKE_lsame( fact, 'f' ) ) { LAPACKE_zsy_trans( matrix_order, uplo, n, af, ldaf, af_t, ldaf_t ); } LAPACKE_zge_trans( matrix_order, n, nrhs, b, ldb, b_t, ldb_t ); /* Call LAPACK function and adjust info */ LAPACK_zsysvxx( &fact, &uplo, &n, &nrhs, a_t, &lda_t, af_t, &ldaf_t, ipiv, equed, s, b_t, &ldb_t, x_t, &ldx_t, rcond, rpvgrw, berr, &n_err_bnds, err_bnds_norm_t, err_bnds_comp_t, &nparams, params, work, rwork, &info ); if( info < 0 ) { info = info - 1; } /* Transpose output matrices */ if( LAPACKE_lsame( fact, 'e' ) && LAPACKE_lsame( *equed, 'y' ) ) { LAPACKE_zsy_trans( LAPACK_COL_MAJOR, uplo, n, a_t, lda_t, a, lda ); } if( LAPACKE_lsame( fact, 'e' ) || LAPACKE_lsame( fact, 'n' ) ) { LAPACKE_zsy_trans( LAPACK_COL_MAJOR, uplo, n, af_t, ldaf_t, af, ldaf ); } if( LAPACKE_lsame( fact, 'f' ) && LAPACKE_lsame( *equed, 'y' ) ) { LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, nrhs, b_t, ldb_t, b, ldb ); } LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, nrhs, x_t, ldx_t, x, ldx ); LAPACKE_dge_trans( LAPACK_COL_MAJOR, nrhs, n_err_bnds, err_bnds_norm_t, nrhs, err_bnds_norm, nrhs ); LAPACKE_dge_trans( LAPACK_COL_MAJOR, nrhs, n_err_bnds, err_bnds_comp_t, nrhs, err_bnds_comp, nrhs ); /* Release memory and exit */ LAPACKE_free( err_bnds_comp_t ); exit_level_5: LAPACKE_free( err_bnds_norm_t ); exit_level_4: LAPACKE_free( x_t ); exit_level_3: LAPACKE_free( b_t ); exit_level_2: LAPACKE_free( af_t ); exit_level_1: LAPACKE_free( a_t ); exit_level_0: if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_zsysvxx_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_zsysvxx_work", info ); } return info; }
lapack_int LAPACKE_chgeqz_work( int matrix_layout, char job, char compq, char compz, lapack_int n, lapack_int ilo, lapack_int ihi, lapack_complex_float* h, lapack_int ldh, lapack_complex_float* t, lapack_int ldt, lapack_complex_float* alpha, lapack_complex_float* beta, lapack_complex_float* q, lapack_int ldq, lapack_complex_float* z, lapack_int ldz, lapack_complex_float* work, lapack_int lwork, float* rwork ) { lapack_int info = 0; if( matrix_layout == LAPACK_COL_MAJOR ) { /* Call LAPACK function and adjust info */ LAPACK_chgeqz( &job, &compq, &compz, &n, &ilo, &ihi, h, &ldh, t, &ldt, alpha, beta, q, &ldq, z, &ldz, work, &lwork, rwork, &info ); if( info < 0 ) { info = info - 1; } } else if( matrix_layout == LAPACK_ROW_MAJOR ) { lapack_int ldh_t = MAX(1,n); lapack_int ldq_t = MAX(1,n); lapack_int ldt_t = MAX(1,n); lapack_int ldz_t = MAX(1,n); lapack_complex_float* h_t = NULL; lapack_complex_float* t_t = NULL; lapack_complex_float* q_t = NULL; lapack_complex_float* z_t = NULL; /* Check leading dimension(s) */ if( ldh < n ) { info = -9; LAPACKE_xerbla( "LAPACKE_chgeqz_work", info ); return info; } if( ldq < n ) { info = -15; LAPACKE_xerbla( "LAPACKE_chgeqz_work", info ); return info; } if( ldt < n ) { info = -11; LAPACKE_xerbla( "LAPACKE_chgeqz_work", info ); return info; } if( ldz < n ) { info = -17; LAPACKE_xerbla( "LAPACKE_chgeqz_work", info ); return info; } /* Query optimal working array(s) size if requested */ if( lwork == -1 ) { LAPACK_chgeqz( &job, &compq, &compz, &n, &ilo, &ihi, h, &ldh_t, t, &ldt_t, alpha, beta, q, &ldq_t, z, &ldz_t, work, &lwork, rwork, &info ); return (info < 0) ? (info - 1) : info; } /* Allocate memory for temporary array(s) */ h_t = (lapack_complex_float*) LAPACKE_malloc( sizeof(lapack_complex_float) * ldh_t * MAX(1,n) ); if( h_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_0; } t_t = (lapack_complex_float*) LAPACKE_malloc( sizeof(lapack_complex_float) * ldt_t * MAX(1,n) ); if( t_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_1; } if( LAPACKE_lsame( compq, 'i' ) || LAPACKE_lsame( compq, 'v' ) ) { q_t = (lapack_complex_float*) LAPACKE_malloc( sizeof(lapack_complex_float) * ldq_t * MAX(1,n) ); if( q_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_2; } } if( LAPACKE_lsame( compz, 'i' ) || LAPACKE_lsame( compz, 'v' ) ) { z_t = (lapack_complex_float*) LAPACKE_malloc( sizeof(lapack_complex_float) * ldz_t * MAX(1,n) ); if( z_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_3; } } /* Transpose input matrices */ LAPACKE_cge_trans( matrix_layout, n, n, h, ldh, h_t, ldh_t ); LAPACKE_cge_trans( matrix_layout, n, n, t, ldt, t_t, ldt_t ); if( LAPACKE_lsame( compq, 'v' ) ) { LAPACKE_cge_trans( matrix_layout, n, n, q, ldq, q_t, ldq_t ); } if( LAPACKE_lsame( compz, 'v' ) ) { LAPACKE_cge_trans( matrix_layout, n, n, z, ldz, z_t, ldz_t ); } /* Call LAPACK function and adjust info */ LAPACK_chgeqz( &job, &compq, &compz, &n, &ilo, &ihi, h_t, &ldh_t, t_t, &ldt_t, alpha, beta, q_t, &ldq_t, z_t, &ldz_t, work, &lwork, rwork, &info ); if( info < 0 ) { info = info - 1; } /* Transpose output matrices */ LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, h_t, ldh_t, h, ldh ); LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, t_t, ldt_t, t, ldt ); if( LAPACKE_lsame( compq, 'i' ) || LAPACKE_lsame( compq, 'v' ) ) { LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, q_t, ldq_t, q, ldq ); } if( LAPACKE_lsame( compz, 'i' ) || LAPACKE_lsame( compz, 'v' ) ) { LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, z_t, ldz_t, z, ldz ); } /* Release memory and exit */ if( LAPACKE_lsame( compz, 'i' ) || LAPACKE_lsame( compz, 'v' ) ) { LAPACKE_free( z_t ); } exit_level_3: if( LAPACKE_lsame( compq, 'i' ) || LAPACKE_lsame( compq, 'v' ) ) { LAPACKE_free( q_t ); } exit_level_2: LAPACKE_free( t_t ); exit_level_1: LAPACKE_free( h_t ); exit_level_0: if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_chgeqz_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_chgeqz_work", info ); } return info; }
lapack_int LAPACKE_zgeev_work( int matrix_order, char jobvl, char jobvr, lapack_int n, lapack_complex_double* a, lapack_int lda, lapack_complex_double* w, lapack_complex_double* vl, lapack_int ldvl, lapack_complex_double* vr, lapack_int ldvr, lapack_complex_double* work, lapack_int lwork, double* rwork ) { lapack_int info = 0; if( matrix_order == LAPACK_COL_MAJOR ) { /* Call LAPACK function and adjust info */ LAPACK_zgeev( &jobvl, &jobvr, &n, a, &lda, w, vl, &ldvl, vr, &ldvr, work, &lwork, rwork, &info ); if( info < 0 ) { info = info - 1; } } else if( matrix_order == LAPACK_ROW_MAJOR ) { lapack_int lda_t = MAX(1,n); lapack_int ldvl_t = MAX(1,n); lapack_int ldvr_t = MAX(1,n); lapack_complex_double* a_t = NULL; lapack_complex_double* vl_t = NULL; lapack_complex_double* vr_t = NULL; /* Check leading dimension(s) */ if( lda < n ) { info = -6; LAPACKE_xerbla( "LAPACKE_zgeev_work", info ); return info; } if( ldvl < n ) { info = -9; LAPACKE_xerbla( "LAPACKE_zgeev_work", info ); return info; } if( ldvr < n ) { info = -11; LAPACKE_xerbla( "LAPACKE_zgeev_work", info ); return info; } /* Query optimal working array(s) size if requested */ if( lwork == -1 ) { LAPACK_zgeev( &jobvl, &jobvr, &n, a, &lda_t, w, vl, &ldvl_t, vr, &ldvr_t, work, &lwork, rwork, &info ); return (info < 0) ? (info - 1) : info; } /* Allocate memory for temporary array(s) */ a_t = (lapack_complex_double*) LAPACKE_malloc( sizeof(lapack_complex_double) * lda_t * MAX(1,n) ); if( a_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_0; } if( LAPACKE_lsame( jobvl, 'v' ) ) { vl_t = (lapack_complex_double*) LAPACKE_malloc( sizeof(lapack_complex_double) * ldvl_t * MAX(1,n) ); if( vl_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_1; } } if( LAPACKE_lsame( jobvr, 'v' ) ) { vr_t = (lapack_complex_double*) LAPACKE_malloc( sizeof(lapack_complex_double) * ldvr_t * MAX(1,n) ); if( vr_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_2; } } /* Transpose input matrices */ LAPACKE_zge_trans( matrix_order, n, n, a, lda, a_t, lda_t ); /* Call LAPACK function and adjust info */ LAPACK_zgeev( &jobvl, &jobvr, &n, a_t, &lda_t, w, vl_t, &ldvl_t, vr_t, &ldvr_t, work, &lwork, rwork, &info ); if( info < 0 ) { info = info - 1; } /* Transpose output matrices */ LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, a_t, lda_t, a, lda ); if( LAPACKE_lsame( jobvl, 'v' ) ) { LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, vl_t, ldvl_t, vl, ldvl ); } if( LAPACKE_lsame( jobvr, 'v' ) ) { LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, vr_t, ldvr_t, vr, ldvr ); } /* Release memory and exit */ if( LAPACKE_lsame( jobvr, 'v' ) ) { LAPACKE_free( vr_t ); } exit_level_2: if( LAPACKE_lsame( jobvl, 'v' ) ) { LAPACKE_free( vl_t ); } exit_level_1: LAPACKE_free( a_t ); exit_level_0: if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_zgeev_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_zgeev_work", info ); } return info; }
lapack_int LAPACKE_strsen( int matrix_order, char job, char compq, const lapack_logical* select, lapack_int n, float* t, lapack_int ldt, float* q, lapack_int ldq, float* wr, float* wi, lapack_int* m, float* s, float* sep ) { lapack_int info = 0; lapack_int liwork = -1; lapack_int lwork = -1; lapack_int* iwork = NULL; float* work = NULL; lapack_int iwork_query; float work_query; if( matrix_order != LAPACK_COL_MAJOR && matrix_order != LAPACK_ROW_MAJOR ) { LAPACKE_xerbla( "LAPACKE_strsen", -1 ); return -1; } #ifndef LAPACK_DISABLE_NAN_CHECK /* Optionally check input matrices for NaNs */ if( LAPACKE_lsame( compq, 'v' ) ) { if( LAPACKE_sge_nancheck( matrix_order, n, n, q, ldq ) ) { return -8; } } if( LAPACKE_sge_nancheck( matrix_order, n, n, t, ldt ) ) { return -6; } #endif /* Query optimal working array(s) size */ info = LAPACKE_strsen_work( matrix_order, job, compq, select, n, t, ldt, q, ldq, wr, wi, m, s, sep, &work_query, lwork, &iwork_query, liwork ); if( info != 0 ) { goto exit_level_0; } liwork = (lapack_int)iwork_query; lwork = (lapack_int)work_query; /* Allocate memory for work arrays */ if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'v' ) ) { iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork ); if( iwork == NULL ) { info = LAPACK_WORK_MEMORY_ERROR; goto exit_level_0; } } work = (float*)LAPACKE_malloc( sizeof(float) * lwork ); if( work == NULL ) { info = LAPACK_WORK_MEMORY_ERROR; goto exit_level_1; } /* Call middle-level interface */ info = LAPACKE_strsen_work( matrix_order, job, compq, select, n, t, ldt, q, ldq, wr, wi, m, s, sep, work, lwork, iwork, liwork ); /* Release memory and exit */ LAPACKE_free( work ); exit_level_1: if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'v' ) ) { LAPACKE_free( iwork ); } exit_level_0: if( info == LAPACK_WORK_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_strsen", info ); } return info; }
lapack_int LAPACKE_zhbevd_2stage_work( int matrix_layout, char jobz, char uplo, lapack_int n, lapack_int kd, lapack_complex_double* ab, lapack_int ldab, double* w, lapack_complex_double* z, lapack_int ldz, lapack_complex_double* work, lapack_int lwork, double* rwork, lapack_int lrwork, lapack_int* iwork, lapack_int liwork ) { lapack_int info = 0; if( matrix_layout == LAPACK_COL_MAJOR ) { /* Call LAPACK function and adjust info */ LAPACK_zhbevd_2stage( &jobz, &uplo, &n, &kd, ab, &ldab, w, z, &ldz, work, &lwork, rwork, &lrwork, iwork, &liwork, &info ); if( info < 0 ) { info = info - 1; } } else if( matrix_layout == LAPACK_ROW_MAJOR ) { lapack_int ldab_t = MAX(1,kd+1); lapack_int ldz_t = MAX(1,n); lapack_complex_double* ab_t = NULL; lapack_complex_double* z_t = NULL; /* Check leading dimension(s) */ if( ldab < n ) { info = -7; LAPACKE_xerbla( "LAPACKE_zhbevd_2stage_work", info ); return info; } if( ldz < n ) { info = -10; LAPACKE_xerbla( "LAPACKE_zhbevd_2stage_work", info ); return info; } /* Query optimal working array(s) size if requested */ if( liwork == -1 || lrwork == -1 || lwork == -1 ) { LAPACK_zhbevd_2stage( &jobz, &uplo, &n, &kd, ab, &ldab_t, w, z, &ldz_t, work, &lwork, rwork, &lrwork, iwork, &liwork, &info ); return (info < 0) ? (info - 1) : info; } /* Allocate memory for temporary array(s) */ ab_t = (lapack_complex_double*) LAPACKE_malloc( sizeof(lapack_complex_double) * ldab_t * MAX(1,n) ); if( ab_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_0; } if( LAPACKE_lsame( jobz, 'v' ) ) { z_t = (lapack_complex_double*) LAPACKE_malloc( sizeof(lapack_complex_double) * ldz_t * MAX(1,n) ); if( z_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_1; } } /* Transpose input matrices */ LAPACKE_zhb_trans( matrix_layout, uplo, n, kd, ab, ldab, ab_t, ldab_t ); /* Call LAPACK function and adjust info */ LAPACK_zhbevd_2stage( &jobz, &uplo, &n, &kd, ab_t, &ldab_t, w, z_t, &ldz_t, work, &lwork, rwork, &lrwork, iwork, &liwork, &info ); if( info < 0 ) { info = info - 1; } /* Transpose output matrices */ LAPACKE_zhb_trans( LAPACK_COL_MAJOR, uplo, n, kd, ab_t, ldab_t, ab, ldab ); if( LAPACKE_lsame( jobz, 'v' ) ) { LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, z_t, ldz_t, z, ldz ); } /* Release memory and exit */ if( LAPACKE_lsame( jobz, 'v' ) ) { LAPACKE_free( z_t ); } exit_level_1: LAPACKE_free( ab_t ); exit_level_0: if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_zhbevd_2stage_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_zhbevd_2stage_work", info ); } return info; }
lapack_int LAPACKE_sggsvd3_work( int matrix_layout, char jobu, char jobv, char jobq, lapack_int m, lapack_int n, lapack_int p, lapack_int* k, lapack_int* l, float* a, lapack_int lda, float* b, lapack_int ldb, float* alpha, float* beta, float* u, lapack_int ldu, float* v, lapack_int ldv, float* q, lapack_int ldq, float* work, lapack_int lwork, lapack_int* iwork ) { lapack_int info = 0; if( matrix_layout == LAPACK_COL_MAJOR ) { /* Call LAPACK function and adjust info */ LAPACK_sggsvd3( &jobu, &jobv, &jobq, &m, &n, &p, k, l, a, &lda, b, &ldb, alpha, beta, u, &ldu, v, &ldv, q, &ldq, work, &lwork, iwork, &info ); if( info < 0 ) { info = info - 1; } } else if( matrix_layout == LAPACK_ROW_MAJOR ) { lapack_int lda_t = MAX(1,m); lapack_int ldb_t = MAX(1,p); lapack_int ldq_t = MAX(1,n); lapack_int ldu_t = MAX(1,m); lapack_int ldv_t = MAX(1,p); float* a_t = NULL; float* b_t = NULL; float* u_t = NULL; float* v_t = NULL; float* q_t = NULL; /* Check leading dimension(s) */ if( lda < n ) { info = -11; LAPACKE_xerbla( "LAPACKE_sggsvd3_work", info ); return info; } if( ldb < n ) { info = -13; LAPACKE_xerbla( "LAPACKE_sggsvd3_work", info ); return info; } if( ldq < n ) { info = -21; LAPACKE_xerbla( "LAPACKE_sggsvd3_work", info ); return info; } if( ldu < m ) { info = -17; LAPACKE_xerbla( "LAPACKE_sggsvd3_work", info ); return info; } if( ldv < p ) { info = -19; LAPACKE_xerbla( "LAPACKE_sggsvd3_work", info ); return info; } /* Query optimal working array(s) size if requested */ if( lwork == -1 ) { LAPACK_sggsvd3( &jobu, &jobv, &jobq, &m, &n, &p, k, l, a, &lda_t, b, &ldb_t, alpha, beta, u, &ldu_t, v, &ldv_t, q, &ldq_t, work, &lwork, iwork, &info ); return (info < 0) ? (info - 1) : info; } /* Allocate memory for temporary array(s) */ a_t = (float*)LAPACKE_malloc( sizeof(float) * lda_t * MAX(1,n) ); if( a_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_0; } b_t = (float*)LAPACKE_malloc( sizeof(float) * ldb_t * MAX(1,n) ); if( b_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_1; } if( LAPACKE_lsame( jobu, 'u' ) ) { u_t = (float*)LAPACKE_malloc( sizeof(float) * ldu_t * MAX(1,m) ); if( u_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_2; } } if( LAPACKE_lsame( jobv, 'v' ) ) { v_t = (float*)LAPACKE_malloc( sizeof(float) * ldv_t * MAX(1,p) ); if( v_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_3; } } if( LAPACKE_lsame( jobq, 'q' ) ) { q_t = (float*)LAPACKE_malloc( sizeof(float) * ldq_t * MAX(1,n) ); if( q_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_4; } } /* Transpose input matrices */ LAPACKE_sge_trans( matrix_layout, m, n, a, lda, a_t, lda_t ); LAPACKE_sge_trans( matrix_layout, p, n, b, ldb, b_t, ldb_t ); /* Call LAPACK function and adjust info */ LAPACK_sggsvd3( &jobu, &jobv, &jobq, &m, &n, &p, k, l, a_t, &lda_t, b_t, &ldb_t, alpha, beta, u_t, &ldu_t, v_t, &ldv_t, q_t, &ldq_t, work, &lwork, iwork, &info ); if( info < 0 ) { info = info - 1; } /* Transpose output matrices */ LAPACKE_sge_trans( LAPACK_COL_MAJOR, m, n, a_t, lda_t, a, lda ); LAPACKE_sge_trans( LAPACK_COL_MAJOR, p, n, b_t, ldb_t, b, ldb ); if( LAPACKE_lsame( jobu, 'u' ) ) { LAPACKE_sge_trans( LAPACK_COL_MAJOR, m, m, u_t, ldu_t, u, ldu ); } if( LAPACKE_lsame( jobv, 'v' ) ) { LAPACKE_sge_trans( LAPACK_COL_MAJOR, p, p, v_t, ldv_t, v, ldv ); } if( LAPACKE_lsame( jobq, 'q' ) ) { LAPACKE_sge_trans( LAPACK_COL_MAJOR, n, n, q_t, ldq_t, q, ldq ); } /* Release memory and exit */ if( LAPACKE_lsame( jobq, 'q' ) ) { LAPACKE_free( q_t ); } exit_level_4: if( LAPACKE_lsame( jobv, 'v' ) ) { LAPACKE_free( v_t ); } exit_level_3: if( LAPACKE_lsame( jobu, 'u' ) ) { LAPACKE_free( u_t ); } exit_level_2: LAPACKE_free( b_t ); exit_level_1: LAPACKE_free( a_t ); exit_level_0: if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_sggsvd3_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_sggsvd3_work", info ); } return info; }
lapack_int LAPACKE_zhseqr_work( int matrix_order, char job, char compz, lapack_int n, lapack_int ilo, lapack_int ihi, lapack_complex_double* h, lapack_int ldh, lapack_complex_double* w, lapack_complex_double* z, lapack_int ldz, lapack_complex_double* work, lapack_int lwork ) { lapack_int info = 0; if( matrix_order == LAPACK_COL_MAJOR ) { /* Call LAPACK function and adjust info */ LAPACK_zhseqr( &job, &compz, &n, &ilo, &ihi, h, &ldh, w, z, &ldz, work, &lwork, &info ); if( info < 0 ) { info = info - 1; } } else if( matrix_order == LAPACK_ROW_MAJOR ) { lapack_int ldh_t = MAX(1,n); lapack_int ldz_t = MAX(1,n); lapack_complex_double* h_t = NULL; lapack_complex_double* z_t = NULL; /* Check leading dimension(s) */ if( ldh < n ) { info = -8; LAPACKE_xerbla( "LAPACKE_zhseqr_work", info ); return info; } if( ldz < n ) { info = -11; LAPACKE_xerbla( "LAPACKE_zhseqr_work", info ); return info; } /* Query optimal working array(s) size if requested */ if( lwork == -1 ) { LAPACK_zhseqr( &job, &compz, &n, &ilo, &ihi, h, &ldh_t, w, z, &ldz_t, work, &lwork, &info ); return (info < 0) ? (info - 1) : info; } /* Allocate memory for temporary array(s) */ h_t = (lapack_complex_double*) LAPACKE_malloc( sizeof(lapack_complex_double) * ldh_t * MAX(1,n) ); if( h_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_0; } if( LAPACKE_lsame( compz, 'i' ) || LAPACKE_lsame( compz, 'v' ) ) { z_t = (lapack_complex_double*) LAPACKE_malloc( sizeof(lapack_complex_double) * ldz_t * MAX(1,n) ); if( z_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_1; } } /* Transpose input matrices */ LAPACKE_zge_trans( matrix_order, n, n, h, ldh, h_t, ldh_t ); if( LAPACKE_lsame( compz, 'v' ) ) { LAPACKE_zge_trans( matrix_order, n, n, z, ldz, z_t, ldz_t ); } /* Call LAPACK function and adjust info */ LAPACK_zhseqr( &job, &compz, &n, &ilo, &ihi, h_t, &ldh_t, w, z_t, &ldz_t, work, &lwork, &info ); if( info < 0 ) { info = info - 1; } /* Transpose output matrices */ LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, h_t, ldh_t, h, ldh ); if( LAPACKE_lsame( compz, 'i' ) || LAPACKE_lsame( compz, 'v' ) ) { LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, z_t, ldz_t, z, ldz ); } /* Release memory and exit */ if( LAPACKE_lsame( compz, 'i' ) || LAPACKE_lsame( compz, 'v' ) ) { LAPACKE_free( z_t ); } exit_level_1: LAPACKE_free( h_t ); exit_level_0: if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_zhseqr_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_zhseqr_work", info ); } return info; }
lapack_int LAPACKE_zhpgvd_work( int matrix_order, lapack_int itype, char jobz, char uplo, lapack_int n, lapack_complex_double* ap, lapack_complex_double* bp, double* w, lapack_complex_double* z, lapack_int ldz, lapack_complex_double* work, lapack_int lwork, double* rwork, lapack_int lrwork, lapack_int* iwork, lapack_int liwork ) { lapack_int info = 0; if( matrix_order == LAPACK_COL_MAJOR ) { /* Call LAPACK function and adjust info */ LAPACK_zhpgvd( &itype, &jobz, &uplo, &n, ap, bp, w, z, &ldz, work, &lwork, rwork, &lrwork, iwork, &liwork, &info ); if( info < 0 ) { info = info - 1; } } else if( matrix_order == LAPACK_ROW_MAJOR ) { lapack_int ldz_t = MAX(1,n); lapack_complex_double* z_t = NULL; lapack_complex_double* ap_t = NULL; lapack_complex_double* bp_t = NULL; /* Check leading dimension(s) */ if( ldz < n ) { info = -10; LAPACKE_xerbla( "LAPACKE_zhpgvd_work", info ); return info; } /* Query optimal working array(s) size if requested */ if( liwork == -1 || lrwork == -1 || lwork == -1 ) { LAPACK_zhpgvd( &itype, &jobz, &uplo, &n, ap, bp, w, z, &ldz_t, work, &lwork, rwork, &lrwork, iwork, &liwork, &info ); return (info < 0) ? (info - 1) : info; } /* Allocate memory for temporary array(s) */ if( LAPACKE_lsame( jobz, 'v' ) ) { z_t = (lapack_complex_double*) LAPACKE_malloc( sizeof(lapack_complex_double) * ldz_t * MAX(1,n) ); if( z_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_0; } } ap_t = (lapack_complex_double*) LAPACKE_malloc( sizeof(lapack_complex_double) * ( MAX(1,n) * MAX(2,n+1) ) / 2 ); if( ap_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_1; } bp_t = (lapack_complex_double*) LAPACKE_malloc( sizeof(lapack_complex_double) * ( MAX(1,n) * MAX(2,n+1) ) / 2 ); if( bp_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_2; } /* Transpose input matrices */ LAPACKE_zhp_trans( matrix_order, uplo, n, ap, ap_t ); LAPACKE_zhp_trans( matrix_order, uplo, n, bp, bp_t ); /* Call LAPACK function and adjust info */ LAPACK_zhpgvd( &itype, &jobz, &uplo, &n, ap_t, bp_t, w, z_t, &ldz_t, work, &lwork, rwork, &lrwork, iwork, &liwork, &info ); if( info < 0 ) { info = info - 1; } /* Transpose output matrices */ if( LAPACKE_lsame( jobz, 'v' ) ) { LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, z_t, ldz_t, z, ldz ); } LAPACKE_zhp_trans( LAPACK_COL_MAJOR, uplo, n, ap_t, ap ); LAPACKE_zhp_trans( LAPACK_COL_MAJOR, uplo, n, bp_t, bp ); /* Release memory and exit */ LAPACKE_free( bp_t ); exit_level_2: LAPACKE_free( ap_t ); exit_level_1: if( LAPACKE_lsame( jobz, 'v' ) ) { LAPACKE_free( z_t ); } exit_level_0: if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_zhpgvd_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_zhpgvd_work", info ); } return info; }
lapack_int LAPACKE_dbbcsd( int matrix_layout, char jobu1, char jobu2, char jobv1t, char jobv2t, char trans, lapack_int m, lapack_int p, lapack_int q, double* theta, double* phi, double* u1, lapack_int ldu1, double* u2, lapack_int ldu2, double* v1t, lapack_int ldv1t, double* v2t, lapack_int ldv2t, double* b11d, double* b11e, double* b12d, double* b12e, double* b21d, double* b21e, double* b22d, double* b22e ) { lapack_int info = 0; lapack_int lwork = -1; double* work = NULL; double work_query; int lapack_layout; if( matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR ) { LAPACKE_xerbla( "LAPACKE_dbbcsd", -1 ); return -1; } if( LAPACKE_lsame( trans, 'n' ) && matrix_layout == LAPACK_COL_MAJOR ) { lapack_layout = LAPACK_COL_MAJOR; } else { lapack_layout = LAPACK_ROW_MAJOR; } #ifndef LAPACK_DISABLE_NAN_CHECK /* Optionally check input matrices for NaNs */ if( LAPACKE_d_nancheck( q-1, phi, 1 ) ) { return -11; } if( LAPACKE_d_nancheck( q, theta, 1 ) ) { return -10; } if( LAPACKE_lsame( jobu1, 'y' ) ) { if( LAPACKE_dge_nancheck( lapack_layout, p, p, u1, ldu1 ) ) { return -12; } } if( LAPACKE_lsame( jobu2, 'y' ) ) { if( LAPACKE_dge_nancheck( lapack_layout, m-p, m-p, u2, ldu2 ) ) { return -14; } } if( LAPACKE_lsame( jobv1t, 'y' ) ) { if( LAPACKE_dge_nancheck( lapack_layout, q, q, v1t, ldv1t ) ) { return -16; } } if( LAPACKE_lsame( jobv2t, 'y' ) ) { if( LAPACKE_dge_nancheck( lapack_layout, m-q, m-q, v2t, ldv2t ) ) { return -18; } } #endif /* Query optimal working array(s) size */ info = LAPACKE_dbbcsd_work( matrix_layout, jobu1, jobu2, jobv1t, jobv2t, trans, m, p, q, theta, phi, u1, ldu1, u2, ldu2, v1t, ldv1t, v2t, ldv2t, b11d, b11e, b12d, b12e, b21d, b21e, b22d, b22e, &work_query, lwork ); if( info != 0 ) { goto exit_level_0; } lwork = (lapack_int)work_query; /* Allocate memory for work arrays */ work = (double*)LAPACKE_malloc( sizeof(double) * lwork ); if( work == NULL ) { info = LAPACK_WORK_MEMORY_ERROR; goto exit_level_0; } /* Call middle-level interface */ info = LAPACKE_dbbcsd_work( matrix_layout, jobu1, jobu2, jobv1t, jobv2t, trans, m, p, q, theta, phi, u1, ldu1, u2, ldu2, v1t, ldv1t, v2t, ldv2t, b11d, b11e, b12d, b12e, b21d, b21e, b22d, b22e, work, lwork ); /* Release memory and exit */ LAPACKE_free( work ); exit_level_0: if( info == LAPACK_WORK_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_dbbcsd", info ); } return info; }
lapack_int LAPACKE_sgesvx_work( int matrix_order, char fact, char trans, lapack_int n, lapack_int nrhs, float* a, lapack_int lda, float* af, lapack_int ldaf, lapack_int* ipiv, char* equed, float* r, float* c, float* b, lapack_int ldb, float* x, lapack_int ldx, float* rcond, float* ferr, float* berr, float* work, lapack_int* iwork ) { lapack_int info = 0; if( matrix_order == LAPACK_COL_MAJOR ) { /* Call LAPACK function and adjust info */ LAPACK_sgesvx( &fact, &trans, &n, &nrhs, a, &lda, af, &ldaf, ipiv, equed, r, c, b, &ldb, x, &ldx, rcond, ferr, berr, work, iwork, &info ); if( info < 0 ) { info = info - 1; } } else if( matrix_order == LAPACK_ROW_MAJOR ) { lapack_int lda_t = MAX(1,n); lapack_int ldaf_t = MAX(1,n); lapack_int ldb_t = MAX(1,n); lapack_int ldx_t = MAX(1,n); float* a_t = NULL; float* af_t = NULL; float* b_t = NULL; float* x_t = NULL; /* Check leading dimension(s) */ if( lda < n ) { info = -7; LAPACKE_xerbla( "LAPACKE_sgesvx_work", info ); return info; } if( ldaf < n ) { info = -9; LAPACKE_xerbla( "LAPACKE_sgesvx_work", info ); return info; } if( ldb < nrhs ) { info = -15; LAPACKE_xerbla( "LAPACKE_sgesvx_work", info ); return info; } if( ldx < nrhs ) { info = -17; LAPACKE_xerbla( "LAPACKE_sgesvx_work", info ); return info; } /* Allocate memory for temporary array(s) */ a_t = (float*)LAPACKE_malloc( sizeof(float) * lda_t * MAX(1,n) ); if( a_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_0; } af_t = (float*)LAPACKE_malloc( sizeof(float) * ldaf_t * MAX(1,n) ); if( af_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_1; } b_t = (float*)LAPACKE_malloc( sizeof(float) * ldb_t * MAX(1,nrhs) ); if( b_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_2; } x_t = (float*)LAPACKE_malloc( sizeof(float) * ldx_t * MAX(1,nrhs) ); if( x_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_3; } /* Transpose input matrices */ LAPACKE_sge_trans( matrix_order, n, n, a, lda, a_t, lda_t ); if( LAPACKE_lsame( fact, 'f' ) ) { LAPACKE_sge_trans( matrix_order, n, n, af, ldaf, af_t, ldaf_t ); } LAPACKE_sge_trans( matrix_order, n, nrhs, b, ldb, b_t, ldb_t ); /* Call LAPACK function and adjust info */ LAPACK_sgesvx( &fact, &trans, &n, &nrhs, a_t, &lda_t, af_t, &ldaf_t, ipiv, equed, r, c, b_t, &ldb_t, x_t, &ldx_t, rcond, ferr, berr, work, iwork, &info ); if( info < 0 ) { info = info - 1; } /* Transpose output matrices */ if( LAPACKE_lsame( fact, 'e' ) && ( LAPACKE_lsame( *equed, 'b' ) || LAPACKE_lsame( *equed, 'c' ) || LAPACKE_lsame( *equed, 'r' ) ) ) { LAPACKE_sge_trans( LAPACK_COL_MAJOR, n, n, a_t, lda_t, a, lda ); } if( LAPACKE_lsame( fact, 'e' ) || LAPACKE_lsame( fact, 'n' ) ) { LAPACKE_sge_trans( LAPACK_COL_MAJOR, n, n, af_t, ldaf_t, af, ldaf ); } if( LAPACKE_lsame( fact, 'f' ) && ( LAPACKE_lsame( *equed, 'b' ) || LAPACKE_lsame( *equed, 'c' ) || LAPACKE_lsame( *equed, 'r' ) ) ) { LAPACKE_sge_trans( LAPACK_COL_MAJOR, n, nrhs, b_t, ldb_t, b, ldb ); } LAPACKE_sge_trans( LAPACK_COL_MAJOR, n, nrhs, x_t, ldx_t, x, ldx ); /* Release memory and exit */ LAPACKE_free( x_t ); exit_level_3: LAPACKE_free( b_t ); exit_level_2: LAPACKE_free( af_t ); exit_level_1: LAPACKE_free( a_t ); exit_level_0: if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_sgesvx_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_sgesvx_work", info ); } return info; }
lapack_int LAPACKE_zsysvxx( int matrix_order, char fact, char uplo, lapack_int n, lapack_int nrhs, lapack_complex_double* a, lapack_int lda, lapack_complex_double* af, lapack_int ldaf, lapack_int* ipiv, char* equed, double* s, lapack_complex_double* b, lapack_int ldb, lapack_complex_double* x, lapack_int ldx, double* rcond, double* rpvgrw, double* berr, lapack_int n_err_bnds, double* err_bnds_norm, double* err_bnds_comp, lapack_int nparams, double* params ) { lapack_int info = 0; double* rwork = NULL; lapack_complex_double* work = NULL; if( matrix_order != LAPACK_COL_MAJOR && matrix_order != LAPACK_ROW_MAJOR ) { LAPACKE_xerbla( "LAPACKE_zsysvxx", -1 ); return -1; } #ifndef LAPACK_DISABLE_NAN_CHECK /* Optionally check input matrices for NaNs */ if( LAPACKE_zsy_nancheck( matrix_order, uplo, n, a, lda ) ) { return -6; } if( LAPACKE_lsame( fact, 'f' ) ) { if( LAPACKE_zsy_nancheck( matrix_order, uplo, n, af, ldaf ) ) { return -8; } } if( LAPACKE_zge_nancheck( matrix_order, n, nrhs, b, ldb ) ) { return -13; } if( nparams>0 ) { if( LAPACKE_d_nancheck( nparams, params, 1 ) ) { return -24; } } if( LAPACKE_lsame( fact, 'f' ) ) { if( LAPACKE_d_nancheck( n, s, 1 ) ) { return -12; } } #endif /* Allocate memory for working array(s) */ rwork = (double*)LAPACKE_malloc( sizeof(double) * MAX(1,3*n) ); if( rwork == NULL ) { info = LAPACK_WORK_MEMORY_ERROR; goto exit_level_0; } work = (lapack_complex_double*) LAPACKE_malloc( sizeof(lapack_complex_double) * MAX(1,2*n) ); if( work == NULL ) { info = LAPACK_WORK_MEMORY_ERROR; goto exit_level_1; } /* Call middle-level interface */ info = LAPACKE_zsysvxx_work( matrix_order, fact, uplo, n, nrhs, a, lda, af, ldaf, ipiv, equed, s, b, ldb, x, ldx, rcond, rpvgrw, berr, n_err_bnds, err_bnds_norm, err_bnds_comp, nparams, params, work, rwork ); /* Release memory and exit */ LAPACKE_free( work ); exit_level_1: LAPACKE_free( rwork ); exit_level_0: if( info == LAPACK_WORK_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_zsysvxx", info ); } return info; }
lapack_int LAPACKE_cheevr_work( int matrix_order, char jobz, char range, char uplo, lapack_int n, lapack_complex_float* a, lapack_int lda, float vl, float vu, lapack_int il, lapack_int iu, float abstol, lapack_int* m, float* w, lapack_complex_float* z, lapack_int ldz, lapack_int* isuppz, lapack_complex_float* work, lapack_int lwork, float* rwork, lapack_int lrwork, lapack_int* iwork, lapack_int liwork ) { lapack_int info = 0; if( matrix_order == LAPACK_COL_MAJOR ) { /* Call LAPACK function and adjust info */ LAPACK_cheevr( &jobz, &range, &uplo, &n, a, &lda, &vl, &vu, &il, &iu, &abstol, m, w, z, &ldz, isuppz, work, &lwork, rwork, &lrwork, iwork, &liwork, &info ); if( info < 0 ) { info = info - 1; } } else if( matrix_order == LAPACK_ROW_MAJOR ) { lapack_int ncols_z = ( LAPACKE_lsame( range, 'a' ) || LAPACKE_lsame( range, 'v' ) ) ? n : ( LAPACKE_lsame( range, 'i' ) ? (iu-il+1) : 1); lapack_int lda_t = MAX(1,n); lapack_int ldz_t = MAX(1,n); lapack_complex_float* a_t = NULL; lapack_complex_float* z_t = NULL; /* Check leading dimension(s) */ if( lda < n ) { info = -7; LAPACKE_xerbla( "LAPACKE_cheevr_work", info ); return info; } if( ldz < ncols_z ) { info = -16; LAPACKE_xerbla( "LAPACKE_cheevr_work", info ); return info; } /* Query optimal working array(s) size if requested */ if( liwork == -1 || lrwork == -1 || lwork == -1 ) { LAPACK_cheevr( &jobz, &range, &uplo, &n, a, &lda_t, &vl, &vu, &il, &iu, &abstol, m, w, z, &ldz_t, isuppz, work, &lwork, rwork, &lrwork, iwork, &liwork, &info ); return (info < 0) ? (info - 1) : info; } /* Allocate memory for temporary array(s) */ a_t = (lapack_complex_float*) LAPACKE_malloc( sizeof(lapack_complex_float) * lda_t * MAX(1,n) ); if( a_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_0; } if( LAPACKE_lsame( jobz, 'v' ) ) { z_t = (lapack_complex_float*) LAPACKE_malloc( sizeof(lapack_complex_float) * ldz_t * MAX(1,ncols_z) ); if( z_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_1; } } /* Transpose input matrices */ LAPACKE_che_trans( matrix_order, uplo, n, a, lda, a_t, lda_t ); /* Call LAPACK function and adjust info */ LAPACK_cheevr( &jobz, &range, &uplo, &n, a_t, &lda_t, &vl, &vu, &il, &iu, &abstol, m, w, z_t, &ldz_t, isuppz, work, &lwork, rwork, &lrwork, iwork, &liwork, &info ); if( info < 0 ) { info = info - 1; } /* Transpose output matrices */ LAPACKE_che_trans( LAPACK_COL_MAJOR, uplo, n, a_t, lda_t, a, lda ); if( LAPACKE_lsame( jobz, 'v' ) ) { LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, ncols_z, z_t, ldz_t, z, ldz ); } /* Release memory and exit */ if( LAPACKE_lsame( jobz, 'v' ) ) { LAPACKE_free( z_t ); } exit_level_1: LAPACKE_free( a_t ); exit_level_0: if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_cheevr_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_cheevr_work", info ); } return info; }
lapack_int LAPACKE_zgees( int matrix_layout, char jobvs, char sort, LAPACK_Z_SELECT1 select, lapack_int n, lapack_complex_double* a, lapack_int lda, lapack_int* sdim, lapack_complex_double* w, lapack_complex_double* vs, lapack_int ldvs ) { lapack_int info = 0; lapack_int lwork = -1; lapack_logical* bwork = NULL; double* rwork = NULL; lapack_complex_double* work = NULL; lapack_complex_double work_query; if( matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR ) { LAPACKE_xerbla( "LAPACKE_zgees", -1 ); return -1; } #ifndef LAPACK_DISABLE_NAN_CHECK /* Optionally check input matrices for NaNs */ if( LAPACKE_zge_nancheck( matrix_layout, n, n, a, lda ) ) { return -6; } #endif /* Allocate memory for working array(s) */ if( LAPACKE_lsame( sort, 's' ) ) { bwork = (lapack_logical*) LAPACKE_malloc( sizeof(lapack_logical) * MAX(1,n) ); if( bwork == NULL ) { info = LAPACK_WORK_MEMORY_ERROR; goto exit_level_0; } } rwork = (double*)LAPACKE_malloc( sizeof(double) * MAX(1,n) ); if( rwork == NULL ) { info = LAPACK_WORK_MEMORY_ERROR; goto exit_level_1; } /* Query optimal working array(s) size */ info = LAPACKE_zgees_work( matrix_layout, jobvs, sort, select, n, a, lda, sdim, w, vs, ldvs, &work_query, lwork, rwork, bwork ); if( info != 0 ) { goto exit_level_2; } lwork = LAPACK_Z2INT( work_query ); /* Allocate memory for work arrays */ work = (lapack_complex_double*) LAPACKE_malloc( sizeof(lapack_complex_double) * lwork ); if( work == NULL ) { info = LAPACK_WORK_MEMORY_ERROR; goto exit_level_2; } /* Call middle-level interface */ info = LAPACKE_zgees_work( matrix_layout, jobvs, sort, select, n, a, lda, sdim, w, vs, ldvs, work, lwork, rwork, bwork ); /* Release memory and exit */ LAPACKE_free( work ); exit_level_2: LAPACKE_free( rwork ); exit_level_1: if( LAPACKE_lsame( sort, 's' ) ) { LAPACKE_free( bwork ); } exit_level_0: if( info == LAPACK_WORK_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_zgees", info ); } return info; }
lapack_int LAPACKE_dlarft_work( int matrix_order, char direct, char storev, lapack_int n, lapack_int k, const double* v, lapack_int ldv, const double* tau, double* t, lapack_int ldt ) { lapack_int info = 0; lapack_int nrows_v, ncols_v; lapack_int ldt_t, ldv_t; double *v_t = NULL, *t_t = NULL; if( matrix_order == LAPACK_COL_MAJOR ) { /* Call LAPACK function and adjust info */ LAPACK_dlarft( &direct, &storev, &n, &k, v, &ldv, tau, t, &ldt ); if( info < 0 ) { info = info - 1; } } else if( matrix_order == LAPACK_ROW_MAJOR ) { nrows_v = LAPACKE_lsame( storev, 'c' ) ? n : ( LAPACKE_lsame( storev, 'r' ) ? k : 1); ncols_v = LAPACKE_lsame( storev, 'c' ) ? k : ( LAPACKE_lsame( storev, 'r' ) ? n : 1); ldt_t = MAX(1,k); ldv_t = MAX(1,nrows_v); /* Check leading dimension(s) */ if( ldt < k ) { info = -10; LAPACKE_xerbla( "LAPACKE_dlarft_work", info ); return info; } if( ldv < ncols_v ) { info = -7; LAPACKE_xerbla( "LAPACKE_dlarft_work", info ); return info; } /* Allocate memory for temporary array(s) */ v_t = (double*) LAPACKE_malloc( sizeof(double) * ldv_t * MAX(1,ncols_v) ); if( v_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_0; } t_t = (double*)LAPACKE_malloc( sizeof(double) * ldt_t * MAX(1,k) ); if( t_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_1; } /* Transpose input matrices */ LAPACKE_dge_trans( matrix_order, nrows_v, ncols_v, v, ldv, v_t, ldv_t ); /* Call LAPACK function and adjust info */ LAPACK_dlarft( &direct, &storev, &n, &k, v_t, &ldv_t, tau, t_t, &ldt_t ); info = 0; /* LAPACK call is ok! */ /* Transpose output matrices */ LAPACKE_dge_trans( LAPACK_COL_MAJOR, k, k, t_t, ldt_t, t, ldt ); /* Release memory and exit */ LAPACKE_free( t_t ); exit_level_1: LAPACKE_free( v_t ); exit_level_0: if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_dlarft_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_dlarft_work", info ); } return info; }
lapack_int LAPACKE_dspgv_work( int matrix_layout, lapack_int itype, char jobz, char uplo, lapack_int n, double* ap, double* bp, double* w, double* z, lapack_int ldz, double* work ) { lapack_int info = 0; if( matrix_layout == LAPACK_COL_MAJOR ) { /* Call LAPACK function and adjust info */ LAPACK_dspgv( &itype, &jobz, &uplo, &n, ap, bp, w, z, &ldz, work, &info ); if( info < 0 ) { info = info - 1; } } else if( matrix_layout == LAPACK_ROW_MAJOR ) { lapack_int ldz_t = MAX(1,n); double* z_t = NULL; double* ap_t = NULL; double* bp_t = NULL; /* Check leading dimension(s) */ if( ldz < n ) { info = -10; LAPACKE_xerbla( "LAPACKE_dspgv_work", info ); return info; } /* Allocate memory for temporary array(s) */ if( LAPACKE_lsame( jobz, 'v' ) ) { z_t = (double*)LAPACKE_malloc( sizeof(double) * ldz_t * MAX(1,n) ); if( z_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_0; } } ap_t = (double*) LAPACKE_malloc( sizeof(double) * ( MAX(1,n) * MAX(2,n+1) ) / 2 ); if( ap_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_1; } bp_t = (double*) LAPACKE_malloc( sizeof(double) * ( MAX(1,n) * MAX(2,n+1) ) / 2 ); if( bp_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_2; } /* Transpose input matrices */ LAPACKE_dsp_trans( matrix_layout, uplo, n, ap, ap_t ); LAPACKE_dsp_trans( matrix_layout, uplo, n, bp, bp_t ); /* Call LAPACK function and adjust info */ LAPACK_dspgv( &itype, &jobz, &uplo, &n, ap_t, bp_t, w, z_t, &ldz_t, work, &info ); if( info < 0 ) { info = info - 1; } /* Transpose output matrices */ if( LAPACKE_lsame( jobz, 'v' ) ) { LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, z_t, ldz_t, z, ldz ); } LAPACKE_dsp_trans( LAPACK_COL_MAJOR, uplo, n, ap_t, ap ); LAPACKE_dsp_trans( LAPACK_COL_MAJOR, uplo, n, bp_t, bp ); /* Release memory and exit */ LAPACKE_free( bp_t ); exit_level_2: LAPACKE_free( ap_t ); exit_level_1: if( LAPACKE_lsame( jobz, 'v' ) ) { LAPACKE_free( z_t ); } exit_level_0: if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_dspgv_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_dspgv_work", info ); } return info; }
lapack_int LAPACKE_csysvx( int matrix_layout, char fact, char uplo, lapack_int n, lapack_int nrhs, const lapack_complex_float* a, lapack_int lda, lapack_complex_float* af, lapack_int ldaf, lapack_int* ipiv, const lapack_complex_float* b, lapack_int ldb, lapack_complex_float* x, lapack_int ldx, float* rcond, float* ferr, float* berr ) { lapack_int info = 0; lapack_int lwork = -1; float* rwork = NULL; lapack_complex_float* work = NULL; lapack_complex_float work_query; if( matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR ) { LAPACKE_xerbla( "LAPACKE_csysvx", -1 ); return -1; } #ifndef LAPACK_DISABLE_NAN_CHECK /* Optionally check input matrices for NaNs */ if( LAPACKE_csy_nancheck( matrix_layout, uplo, n, a, lda ) ) { return -6; } if( LAPACKE_lsame( fact, 'f' ) ) { if( LAPACKE_csy_nancheck( matrix_layout, uplo, n, af, ldaf ) ) { return -8; } } if( LAPACKE_cge_nancheck( matrix_layout, n, nrhs, b, ldb ) ) { return -11; } #endif /* Allocate memory for working array(s) */ rwork = (float*)LAPACKE_malloc( sizeof(float) * MAX(1,n) ); if( rwork == NULL ) { info = LAPACK_WORK_MEMORY_ERROR; goto exit_level_0; } /* Query optimal working array(s) size */ info = LAPACKE_csysvx_work( matrix_layout, fact, uplo, n, nrhs, a, lda, af, ldaf, ipiv, b, ldb, x, ldx, rcond, ferr, berr, &work_query, lwork, rwork ); if( info != 0 ) { goto exit_level_1; } lwork = LAPACK_C2INT( work_query ); /* Allocate memory for work arrays */ work = (lapack_complex_float*) LAPACKE_malloc( sizeof(lapack_complex_float) * lwork ); if( work == NULL ) { info = LAPACK_WORK_MEMORY_ERROR; goto exit_level_1; } /* Call middle-level interface */ info = LAPACKE_csysvx_work( matrix_layout, fact, uplo, n, nrhs, a, lda, af, ldaf, ipiv, b, ldb, x, ldx, rcond, ferr, berr, work, lwork, rwork ); /* Release memory and exit */ LAPACKE_free( work ); exit_level_1: LAPACKE_free( rwork ); exit_level_0: if( info == LAPACK_WORK_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_csysvx", info ); } return info; }
lapack_int LAPACKE_zpbsvx( int matrix_layout, char fact, char uplo, lapack_int n, lapack_int kd, lapack_int nrhs, lapack_complex_double* ab, lapack_int ldab, lapack_complex_double* afb, lapack_int ldafb, char* equed, double* s, lapack_complex_double* b, lapack_int ldb, lapack_complex_double* x, lapack_int ldx, double* rcond, double* ferr, double* berr ) { lapack_int info = 0; double* rwork = NULL; lapack_complex_double* work = NULL; if( matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR ) { LAPACKE_xerbla( "LAPACKE_zpbsvx", -1 ); return -1; } #ifndef LAPACK_DISABLE_NAN_CHECK /* Optionally check input matrices for NaNs */ if( LAPACKE_zpb_nancheck( matrix_layout, uplo, n, kd, ab, ldab ) ) { return -7; } if( LAPACKE_lsame( fact, 'f' ) ) { if( LAPACKE_zpb_nancheck( matrix_layout, uplo, n, kd, afb, ldafb ) ) { return -9; } } if( LAPACKE_zge_nancheck( matrix_layout, n, nrhs, b, ldb ) ) { return -13; } if( LAPACKE_lsame( fact, 'f' ) && LAPACKE_lsame( *equed, 'y' ) ) { if( LAPACKE_d_nancheck( n, s, 1 ) ) { return -12; } } #endif /* Allocate memory for working array(s) */ rwork = (double*)LAPACKE_malloc( sizeof(double) * MAX(1,n) ); if( rwork == NULL ) { info = LAPACK_WORK_MEMORY_ERROR; goto exit_level_0; } work = (lapack_complex_double*) LAPACKE_malloc( sizeof(lapack_complex_double) * MAX(1,2*n) ); if( work == NULL ) { info = LAPACK_WORK_MEMORY_ERROR; goto exit_level_1; } /* Call middle-level interface */ info = LAPACKE_zpbsvx_work( matrix_layout, fact, uplo, n, kd, nrhs, ab, ldab, afb, ldafb, equed, s, b, ldb, x, ldx, rcond, ferr, berr, work, rwork ); /* Release memory and exit */ LAPACKE_free( work ); exit_level_1: LAPACKE_free( rwork ); exit_level_0: if( info == LAPACK_WORK_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_zpbsvx", info ); } return info; }
lapack_int LAPACKE_zupmtr_work( int matrix_layout, char side, char uplo, char trans, lapack_int m, lapack_int n, const lapack_complex_double* ap, const lapack_complex_double* tau, lapack_complex_double* c, lapack_int ldc, lapack_complex_double* work ) { lapack_int info = 0; if( matrix_layout == LAPACK_COL_MAJOR ) { /* Call LAPACK function and adjust info */ LAPACK_zupmtr( &side, &uplo, &trans, &m, &n, ap, tau, c, &ldc, work, &info ); if( info < 0 ) { info = info - 1; } } else if( matrix_layout == LAPACK_ROW_MAJOR ) { lapack_int r = LAPACKE_lsame( side, 'l' ) ? m : n; lapack_int ldc_t = MAX(1,m); lapack_complex_double* c_t = NULL; lapack_complex_double* ap_t = NULL; /* Check leading dimension(s) */ if( ldc < n ) { info = -10; LAPACKE_xerbla( "LAPACKE_zupmtr_work", info ); return info; } /* Allocate memory for temporary array(s) */ c_t = (lapack_complex_double*) LAPACKE_malloc( sizeof(lapack_complex_double) * ldc_t * MAX(1,n) ); if( c_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_0; } ap_t = (lapack_complex_double*) LAPACKE_malloc( sizeof(lapack_complex_double) * ( MAX(1,r) * MAX(2,r+1) ) / 2 ); if( ap_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_1; } /* Transpose input matrices */ LAPACKE_zge_trans( matrix_layout, m, n, c, ldc, c_t, ldc_t ); LAPACKE_zpp_trans( matrix_layout, uplo, r, ap, ap_t ); /* Call LAPACK function and adjust info */ LAPACK_zupmtr( &side, &uplo, &trans, &m, &n, ap_t, tau, c_t, &ldc_t, work, &info ); if( info < 0 ) { info = info - 1; } /* Transpose output matrices */ LAPACKE_zge_trans( LAPACK_COL_MAJOR, m, n, c_t, ldc_t, c, ldc ); /* Release memory and exit */ LAPACKE_free( ap_t ); exit_level_1: LAPACKE_free( c_t ); exit_level_0: if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_zupmtr_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_zupmtr_work", info ); } return info; }
lapack_int LAPACKE_dorcsd2by1_work( int matrix_layout, char jobu1, char jobu2, char jobv1t, lapack_int m, lapack_int p, lapack_int q, double* x11, lapack_int ldx11, double* x21, lapack_int ldx21, double* theta, double* u1, lapack_int ldu1, double* u2, lapack_int ldu2, double* v1t, lapack_int ldv1t, double* work, lapack_int lwork, lapack_int* iwork ) { lapack_int info = 0; if( matrix_layout == LAPACK_COL_MAJOR ) { /* Call LAPACK function and adjust info */ LAPACK_dorcsd2by1( &jobu1, &jobu2, &jobv1t, &m, &p, &q, x11, &ldx11, x21, &ldx21, theta, u1, &ldu1, u2, &ldu2, v1t, &ldv1t, work, &lwork, iwork, &info ); if( info < 0 ) { info = info - 1; } } else if( matrix_layout == LAPACK_ROW_MAJOR ) { lapack_int nrows_x11 = p; lapack_int nrows_x21 = m-p; lapack_int nrows_u1 = ( LAPACKE_lsame( jobu1, 'y' ) ? p : 1); lapack_int nrows_u2 = ( LAPACKE_lsame( jobu2, 'y' ) ? m-p : 1); lapack_int nrows_v1t = ( LAPACKE_lsame( jobv1t, 'y' ) ? q : 1); lapack_int ldu1_t = MAX(1,nrows_u1); lapack_int ldu2_t = MAX(1,nrows_u2); lapack_int ldv1t_t = MAX(1,nrows_v1t); lapack_int ldx11_t = MAX(1,nrows_x11); lapack_int ldx21_t = MAX(1,nrows_x21); double* x11_t = NULL; double* x21_t = NULL; double* u1_t = NULL; double* u2_t = NULL; double* v1t_t = NULL; /* Check leading dimension(s) */ if( ldu1 < p ) { info = -21; LAPACKE_xerbla( "LAPACKE_dorcsd2by1_work", info ); return info; } if( ldu2 < m-p ) { info = -23; LAPACKE_xerbla( "LAPACKE_dorcsd2by1_work", info ); return info; } if( ldv1t < q ) { info = -25; LAPACKE_xerbla( "LAPACKE_dorcsd2by1_work", info ); return info; } if( ldx11 < q ) { info = -12; LAPACKE_xerbla( "LAPACKE_dorcsd2by1_work", info ); return info; } if( ldx21 < q ) { info = -16; LAPACKE_xerbla( "LAPACKE_dorcsd2by1_work", info ); return info; } /* Query optimal working array(s) size if requested */ if( lwork == -1 ) { LAPACK_dorcsd2by1( &jobu1, &jobu2, &jobv1t, &m, &p, &q, x11, &ldx11, x21, &ldx21, theta, u1, &ldu1, u2, &ldu2, v1t, &ldv1t, work, &lwork, iwork, &info ); return (info < 0) ? (info - 1) : info; } /* Allocate memory for temporary array(s) */ x11_t = (double*)LAPACKE_malloc( sizeof(double) * ldx11_t * MAX(1,q) ); if( x11_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_0; } x21_t = (double*)LAPACKE_malloc( sizeof(double) * ldx21_t * MAX(1,q) ); if( x21_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_1; } if( LAPACKE_lsame( jobu1, 'y' ) ) { u1_t = (double*) LAPACKE_malloc( sizeof(double) * ldu1_t * MAX(1,p) ); if( u1_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_2; } } if( LAPACKE_lsame( jobu2, 'y' ) ) { u2_t = (double*) LAPACKE_malloc( sizeof(double) * ldu2_t * MAX(1,m-p) ); if( u2_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_3; } } if( LAPACKE_lsame( jobv1t, 'y' ) ) { v1t_t = (double*) LAPACKE_malloc( sizeof(double) * ldv1t_t * MAX(1,q) ); if( v1t_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_4; } } /* Transpose input matrices */ LAPACKE_dge_trans( matrix_layout, nrows_x11, q, x11, ldx11, x11_t, ldx11_t ); LAPACKE_dge_trans( matrix_layout, nrows_x21, q, x21, ldx21, x21_t, ldx21_t ); /* Call LAPACK function and adjust info */ LAPACK_dorcsd2by1( &jobu1, &jobu2, &jobv1t, &m, &p, &q, x11, &ldx11, x21, &ldx21, theta, u1, &ldu1, u2, &ldu2, v1t, &ldv1t, work, &lwork, iwork, &info ); if( info < 0 ) { info = info - 1; } /* Transpose output matrices */ LAPACKE_dge_trans( LAPACK_COL_MAJOR, nrows_x11, q, x11_t, ldx11_t, x11, ldx11 ); LAPACKE_dge_trans( LAPACK_COL_MAJOR, nrows_x21, q, x21_t, ldx21_t, x21, ldx21 ); if( LAPACKE_lsame( jobu1, 'y' ) ) { LAPACKE_dge_trans( LAPACK_COL_MAJOR, nrows_u1, p, u1_t, ldu1_t, u1, ldu1 ); } if( LAPACKE_lsame( jobu2, 'y' ) ) { LAPACKE_dge_trans( LAPACK_COL_MAJOR, nrows_u2, m-p, u2_t, ldu2_t, u2, ldu2 ); } if( LAPACKE_lsame( jobv1t, 'y' ) ) { LAPACKE_dge_trans( LAPACK_COL_MAJOR, nrows_v1t, q, v1t_t, ldv1t_t, v1t, ldv1t ); } /* Release memory and exit */ if( LAPACKE_lsame( jobv1t, 'y' ) ) { LAPACKE_free( v1t_t ); } exit_level_4: if( LAPACKE_lsame( jobu2, 'y' ) ) { LAPACKE_free( u2_t ); } exit_level_3: if( LAPACKE_lsame( jobu1, 'y' ) ) { LAPACKE_free( u1_t ); } exit_level_2: LAPACKE_free( x21_t ); exit_level_1: LAPACKE_free( x11_t ); exit_level_0: if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_dorcsd2by1_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_dorcsd2by1_work", info ); } return info; }
lapack_int LAPACKE_dgesvd_work( int matrix_layout, char jobu, char jobvt, lapack_int m, lapack_int n, double* a, lapack_int lda, double* s, double* u, lapack_int ldu, double* vt, lapack_int ldvt, double* work, lapack_int lwork ) { lapack_int info = 0; if( matrix_layout == LAPACK_COL_MAJOR ) { /* Call LAPACK function and adjust info */ LAPACK_dgesvd( &jobu, &jobvt, &m, &n, a, &lda, s, u, &ldu, vt, &ldvt, work, &lwork, &info ); if( info < 0 ) { info = info - 1; } } else if( matrix_layout == LAPACK_ROW_MAJOR ) { lapack_int nrows_u = ( LAPACKE_lsame( jobu, 'a' ) || LAPACKE_lsame( jobu, 's' ) ) ? m : 1; lapack_int ncols_u = LAPACKE_lsame( jobu, 'a' ) ? m : ( LAPACKE_lsame( jobu, 's' ) ? MIN(m,n) : 1); lapack_int nrows_vt = LAPACKE_lsame( jobvt, 'a' ) ? n : ( LAPACKE_lsame( jobvt, 's' ) ? MIN(m,n) : 1); lapack_int lda_t = MAX(1,m); lapack_int ldu_t = MAX(1,nrows_u); lapack_int ldvt_t = MAX(1,nrows_vt); double* a_t = NULL; double* u_t = NULL; double* vt_t = NULL; /* Check leading dimension(s) */ if( lda < n ) { info = -7; LAPACKE_xerbla( "LAPACKE_dgesvd_work", info ); return info; } if( ldu < ncols_u ) { info = -10; LAPACKE_xerbla( "LAPACKE_dgesvd_work", info ); return info; } if( ldvt < n ) { info = -12; LAPACKE_xerbla( "LAPACKE_dgesvd_work", info ); return info; } /* Query optimal working array(s) size if requested */ if( lwork == -1 ) { LAPACK_dgesvd( &jobu, &jobvt, &m, &n, a, &lda_t, s, u, &ldu_t, vt, &ldvt_t, work, &lwork, &info ); return (info < 0) ? (info - 1) : info; } /* Allocate memory for temporary array(s) */ a_t = (double*)LAPACKE_malloc( sizeof(double) * lda_t * MAX(1,n) ); if( a_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_0; } if( LAPACKE_lsame( jobu, 'a' ) || LAPACKE_lsame( jobu, 's' ) ) { u_t = (double*) LAPACKE_malloc( sizeof(double) * ldu_t * MAX(1,ncols_u) ); if( u_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_1; } } if( LAPACKE_lsame( jobvt, 'a' ) || LAPACKE_lsame( jobvt, 's' ) ) { vt_t = (double*) LAPACKE_malloc( sizeof(double) * ldvt_t * MAX(1,n) ); if( vt_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_2; } } /* Transpose input matrices */ LAPACKE_dge_trans( matrix_layout, m, n, a, lda, a_t, lda_t ); /* Call LAPACK function and adjust info */ LAPACK_dgesvd( &jobu, &jobvt, &m, &n, a_t, &lda_t, s, u_t, &ldu_t, vt_t, &ldvt_t, work, &lwork, &info ); if( info < 0 ) { info = info - 1; } /* Transpose output matrices */ LAPACKE_dge_trans( LAPACK_COL_MAJOR, m, n, a_t, lda_t, a, lda ); if( LAPACKE_lsame( jobu, 'a' ) || LAPACKE_lsame( jobu, 's' ) ) { LAPACKE_dge_trans( LAPACK_COL_MAJOR, nrows_u, ncols_u, u_t, ldu_t, u, ldu ); } if( LAPACKE_lsame( jobvt, 'a' ) || LAPACKE_lsame( jobvt, 's' ) ) { LAPACKE_dge_trans( LAPACK_COL_MAJOR, nrows_vt, n, vt_t, ldvt_t, vt, ldvt ); } /* Release memory and exit */ if( LAPACKE_lsame( jobvt, 'a' ) || LAPACKE_lsame( jobvt, 's' ) ) { LAPACKE_free( vt_t ); } exit_level_2: if( LAPACKE_lsame( jobu, 'a' ) || LAPACKE_lsame( jobu, 's' ) ) { LAPACKE_free( u_t ); } exit_level_1: LAPACKE_free( a_t ); exit_level_0: if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_dgesvd_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_dgesvd_work", info ); } return info; }
lapack_int LAPACKE_cppsvx( int matrix_layout, char fact, char uplo, lapack_int n, lapack_int nrhs, lapack_complex_float* ap, lapack_complex_float* afp, char* equed, float* s, lapack_complex_float* b, lapack_int ldb, lapack_complex_float* x, lapack_int ldx, float* rcond, float* ferr, float* berr ) { lapack_int info = 0; float* rwork = NULL; lapack_complex_float* work = NULL; if( matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR ) { LAPACKE_xerbla( "LAPACKE_cppsvx", -1 ); return -1; } #ifndef LAPACK_DISABLE_NAN_CHECK if( LAPACKE_get_nancheck() ) { /* Optionally check input matrices for NaNs */ if( LAPACKE_lsame( fact, 'f' ) ) { if( LAPACKE_cpp_nancheck( n, afp ) ) { return -7; } } if( LAPACKE_cpp_nancheck( n, ap ) ) { return -6; } if( LAPACKE_cge_nancheck( matrix_layout, n, nrhs, b, ldb ) ) { return -10; } if( LAPACKE_lsame( fact, 'f' ) && LAPACKE_lsame( *equed, 'y' ) ) { if( LAPACKE_s_nancheck( n, s, 1 ) ) { return -9; } } } #endif /* Allocate memory for working array(s) */ rwork = (float*)LAPACKE_malloc( sizeof(float) * MAX(1,n) ); if( rwork == NULL ) { info = LAPACK_WORK_MEMORY_ERROR; goto exit_level_0; } work = (lapack_complex_float*) LAPACKE_malloc( sizeof(lapack_complex_float) * MAX(1,2*n) ); if( work == NULL ) { info = LAPACK_WORK_MEMORY_ERROR; goto exit_level_1; } /* Call middle-level interface */ info = LAPACKE_cppsvx_work( matrix_layout, fact, uplo, n, nrhs, ap, afp, equed, s, b, ldb, x, ldx, rcond, ferr, berr, work, rwork ); /* Release memory and exit */ LAPACKE_free( work ); exit_level_1: LAPACKE_free( rwork ); exit_level_0: if( info == LAPACK_WORK_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_cppsvx", info ); } return info; }