示例#1
0
lapack_int LAPACKE_ctrtri_work( int matrix_layout, char uplo, char diag,
                                lapack_int n, lapack_complex_float* a,
                                lapack_int lda )
{
    lapack_int info = 0;
    if( matrix_layout == LAPACK_COL_MAJOR ) {
        /* Call LAPACK function and adjust info */
        LAPACK_ctrtri( &uplo, &diag, &n, a, &lda, &info );
        if( info < 0 ) {
            info = info - 1;
        }
    } else if( matrix_layout == LAPACK_ROW_MAJOR ) {
        lapack_int lda_t = MAX(1,n);
        lapack_complex_float* a_t = NULL;
        /* Check leading dimension(s) */
        if( lda < n ) {
            info = -6;
            LAPACKE_xerbla( "LAPACKE_ctrtri_work", info );
            return 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;
        }
        /* Transpose input matrices */
        LAPACKE_ctr_trans( matrix_layout, uplo, diag, n, a, lda, a_t, lda_t );
        /* Call LAPACK function and adjust info */
        LAPACK_ctrtri( &uplo, &diag, &n, a_t, &lda_t, &info );
        if( info < 0 ) {
            info = info - 1;
        }
        /* Transpose output matrices */
        LAPACKE_ctr_trans( LAPACK_COL_MAJOR, uplo, diag, n, a_t, lda_t, a,
                           lda );
        /* Release memory and exit */
        LAPACKE_free( a_t );
exit_level_0:
        if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
            LAPACKE_xerbla( "LAPACKE_ctrtri_work", info );
        }
    } else {
        info = -1;
        LAPACKE_xerbla( "LAPACKE_ctrtri_work", info );
    }
    return info;
}
示例#2
0
lapack_int LAPACKE_ctrrfs_work( int matrix_order, char uplo, char trans,
                                char diag, lapack_int n, lapack_int nrhs,
                                const lapack_complex_float* a, lapack_int lda,
                                const lapack_complex_float* b, lapack_int ldb,
                                const lapack_complex_float* x, lapack_int ldx,
                                float* ferr, float* berr,
                                lapack_complex_float* work, float* rwork )
{
    lapack_int info = 0;
    if( matrix_order == LAPACK_COL_MAJOR ) {
        /* Call LAPACK function and adjust info */
        LAPACK_ctrrfs( &uplo, &trans, &diag, &n, &nrhs, a, &lda, b, &ldb, x,
                       &ldx, ferr, berr, 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 ldb_t = MAX(1,n);
        lapack_int ldx_t = MAX(1,n);
        lapack_complex_float* a_t = NULL;
        lapack_complex_float* b_t = NULL;
        lapack_complex_float* x_t = NULL;
        /* Check leading dimension(s) */
        if( lda < n ) {
            info = -8;
            LAPACKE_xerbla( "LAPACKE_ctrrfs_work", info );
            return info;
        }
        if( ldb < nrhs ) {
            info = -10;
            LAPACKE_xerbla( "LAPACKE_ctrrfs_work", info );
            return info;
        }
        if( ldx < nrhs ) {
            info = -12;
            LAPACKE_xerbla( "LAPACKE_ctrrfs_work", info );
            return 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;
        }
        b_t = (lapack_complex_float*)
            LAPACKE_malloc( sizeof(lapack_complex_float) *
                            ldb_t * MAX(1,nrhs) );
        if( b_t == NULL ) {
            info = LAPACK_TRANSPOSE_MEMORY_ERROR;
            goto exit_level_1;
        }
        x_t = (lapack_complex_float*)
            LAPACKE_malloc( sizeof(lapack_complex_float) *
                            ldx_t * MAX(1,nrhs) );
        if( x_t == NULL ) {
            info = LAPACK_TRANSPOSE_MEMORY_ERROR;
            goto exit_level_2;
        }
        /* Transpose input matrices */
        LAPACKE_ctr_trans( matrix_order, uplo, diag, n, a, lda, a_t, lda_t );
        LAPACKE_cge_trans( matrix_order, n, nrhs, b, ldb, b_t, ldb_t );
        LAPACKE_cge_trans( matrix_order, n, nrhs, x, ldx, x_t, ldx_t );
        /* Call LAPACK function and adjust info */
        LAPACK_ctrrfs( &uplo, &trans, &diag, &n, &nrhs, a_t, &lda_t, b_t,
                       &ldb_t, x_t, &ldx_t, ferr, berr, work, rwork, &info );
        if( info < 0 ) {
            info = info - 1;
        }
        /* Release memory and exit */
        LAPACKE_free( x_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_ctrrfs_work", info );
        }
    } else {
        info = -1;
        LAPACKE_xerbla( "LAPACKE_ctrrfs_work", info );
    }
    return info;
}
lapack_int LAPACKE_clarfb_work( int matrix_order, char side, char trans,
                                char direct, char storev, lapack_int m,
                                lapack_int n, lapack_int k,
                                const lapack_complex_float* v, lapack_int ldv,
                                const lapack_complex_float* t, lapack_int ldt,
                                lapack_complex_float* c, lapack_int ldc,
                                lapack_complex_float* work, lapack_int ldwork )
{
    lapack_int info = 0;
    if( matrix_order == LAPACK_COL_MAJOR ) {
        /* Call LAPACK function and adjust info */
        LAPACK_clarfb( &side, &trans, &direct, &storev, &m, &n, &k, v, &ldv, t,
                       &ldt, c, &ldc, work, &ldwork );
        if( info < 0 ) {
            info = info - 1;
        }
    } else if( matrix_order == LAPACK_ROW_MAJOR ) {
        lapack_int nrows_v = ( LAPACKE_lsame( storev, 'c' ) &&
                               LAPACKE_lsame( side, 'l' ) ) ? m :
                             ( ( LAPACKE_lsame( storev, 'c' ) &&
                                 LAPACKE_lsame( side, 'r' ) ) ? n :
                               ( LAPACKE_lsame( storev, 'r' ) ? k : 1) );
        lapack_int ncols_v = LAPACKE_lsame( storev, 'c' ) ? k :
                             ( ( LAPACKE_lsame( storev, 'r' ) &&
                                 LAPACKE_lsame( side, 'l' ) ) ? m :
                               ( ( LAPACKE_lsame( storev, 'r' ) &&
                                   LAPACKE_lsame( side, 'r' ) ) ? n : 1) );
        lapack_int ldc_t = MAX(1,m);
        lapack_int ldt_t = MAX(1,k);
        lapack_int ldv_t = MAX(1,nrows_v);
        lapack_complex_float* v_t = NULL;
        lapack_complex_float* t_t = NULL;
        lapack_complex_float* c_t = NULL;
        /* Check leading dimension(s) */
        if( ldc < n ) {
            info = -14;
            LAPACKE_xerbla( "LAPACKE_clarfb_work", info );
            return info;
        }
        if( ldt < k ) {
            info = -12;
            LAPACKE_xerbla( "LAPACKE_clarfb_work", info );
            return info;
        }
        if( ldv < ncols_v ) {
            info = -10;
            LAPACKE_xerbla( "LAPACKE_clarfb_work", info );
            return info;
        }
        /* Allocate memory for temporary array(s) */
        v_t = (lapack_complex_float*)
              LAPACKE_malloc( sizeof(lapack_complex_float) *
                              ldv_t * MAX(1,ncols_v) );
        if( v_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,k) );
        if( t_t == NULL ) {
            info = LAPACK_TRANSPOSE_MEMORY_ERROR;
            goto exit_level_1;
        }
        c_t = (lapack_complex_float*)
              LAPACKE_malloc( sizeof(lapack_complex_float) * ldc_t * MAX(1,n) );
        if( c_t == NULL ) {
            info = LAPACK_TRANSPOSE_MEMORY_ERROR;
            goto exit_level_2;
        }
        /* Transpose input matrices */
        if( LAPACKE_lsame( storev, 'c' ) && LAPACKE_lsame( direct, 'f' ) ) {
            LAPACKE_ctr_trans( matrix_order, 'l', 'u', k, v, ldv, v_t, ldv_t );
            LAPACKE_cge_trans( matrix_order, nrows_v-k, ncols_v, &v[k*ldv], ldv,
                               &v_t[k], ldv_t );
        } else if( LAPACKE_lsame( storev, 'c' ) &&
                   LAPACKE_lsame( direct, 'b' ) ) {
            if( k > nrows_v ) {
                LAPACKE_xerbla( "LAPACKE_clarfb_work", -8 );
                return -8;
            }
            LAPACKE_ctr_trans( matrix_order, 'u', 'u', k, &v[(nrows_v-k)*ldv],
                               ldv, &v_t[nrows_v-k], ldv_t );
            LAPACKE_cge_trans( matrix_order, nrows_v-k, ncols_v, v, ldv, v_t,
                               ldv_t );
        } else if( LAPACKE_lsame( storev, 'r' ) &&
                   LAPACKE_lsame( direct, 'f' ) ) {
            LAPACKE_ctr_trans( matrix_order, 'u', 'u', k, v, ldv, v_t, ldv_t );
            LAPACKE_cge_trans( matrix_order, nrows_v, ncols_v-k, &v[k], ldv,
                               &v_t[k*ldv_t], ldv_t );
        } else if( LAPACKE_lsame( storev, 'r' ) &&
                   LAPACKE_lsame( direct, 'f' ) ) {
            if( k > ncols_v ) {
                LAPACKE_xerbla( "LAPACKE_clarfb_work", -8 );
                return -8;
            }
            LAPACKE_ctr_trans( matrix_order, 'l', 'u', k, &v[ncols_v-k], ldv,
                               &v_t[(ncols_v-k)*ldv_t], ldv_t );
            LAPACKE_cge_trans( matrix_order, nrows_v, ncols_v-k, v, ldv, v_t,
                               ldv_t );
        }
        LAPACKE_cge_trans( matrix_order, k, k, t, ldt, t_t, ldt_t );
        LAPACKE_cge_trans( matrix_order, m, n, c, ldc, c_t, ldc_t );
        /* Call LAPACK function and adjust info */
        LAPACK_clarfb( &side, &trans, &direct, &storev, &m, &n, &k, v_t, &ldv_t,
                       t_t, &ldt_t, c_t, &ldc_t, work, &ldwork );
        info = 0;  /* LAPACK call is ok! */
        /* Transpose output matrices */
        LAPACKE_cge_trans( LAPACK_COL_MAJOR, m, n, c_t, ldc_t, c, ldc );
        /* Release memory and exit */
        LAPACKE_free( c_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_clarfb_work", info );
        }
    } else {
        info = -1;
        LAPACKE_xerbla( "LAPACKE_clarfb_work", info );
    }
    return info;
}