Ejemplo n.º 1
0
lapack_int LAPACKE_dsbev( int matrix_order, char jobz, char uplo, lapack_int n,
                          lapack_int kd, double* ab, lapack_int ldab, double* w,
                          double* z, lapack_int ldz )
{
    lapack_int info = 0;
    double* work = NULL;
    if( matrix_order != LAPACK_COL_MAJOR && matrix_order != LAPACK_ROW_MAJOR ) {
        LAPACKE_xerbla( "LAPACKE_dsbev", -1 );
        return -1;
    }
#ifndef LAPACK_DISABLE_NAN_CHECK
    /* Optionally check input matrices for NaNs */
    if( LAPACKE_dsb_nancheck( matrix_order, uplo, n, kd, ab, ldab ) ) {
        return -6;
    }
#endif
    /* Allocate memory for working array(s) */
    work = (double*)LAPACKE_malloc( sizeof(double) * MAX(1,3*n-2) );
    if( work == NULL ) {
        info = LAPACK_WORK_MEMORY_ERROR;
        goto exit_level_0;
    }
    /* Call middle-level interface */
    info = LAPACKE_dsbev_work( matrix_order, jobz, uplo, n, kd, ab, ldab, w, z,
                               ldz, work );
    /* Release memory and exit */
    LAPACKE_free( work );
exit_level_0:
    if( info == LAPACK_WORK_MEMORY_ERROR ) {
        LAPACKE_xerbla( "LAPACKE_dsbev", info );
    }
    return info;
}
Ejemplo n.º 2
0
lapack_int LAPACKE_dsbevx( int matrix_layout, char jobz, char range, char uplo,
                           lapack_int n, lapack_int kd, double* ab,
                           lapack_int ldab, double* q, lapack_int ldq,
                           double vl, double vu, lapack_int il, lapack_int iu,
                           double abstol, lapack_int* m, double* w, double* z,
                           lapack_int ldz, lapack_int* ifail )
{
    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_dsbevx", -1 );
        return -1;
    }
#ifndef LAPACK_DISABLE_NAN_CHECK
    /* Optionally check input matrices for NaNs */
    if( LAPACKE_dsb_nancheck( matrix_layout, uplo, n, kd, ab, ldab ) ) {
        return -7;
    }
    if( LAPACKE_d_nancheck( 1, &abstol, 1 ) ) {
        return -15;
    }
    if( LAPACKE_lsame( range, 'v' ) ) {
        if( LAPACKE_d_nancheck( 1, &vl, 1 ) ) {
            return -11;
        }
    }
    if( LAPACKE_lsame( range, 'v' ) ) {
        if( LAPACKE_d_nancheck( 1, &vu, 1 ) ) {
            return -12;
        }
    }
#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;
    }
    work = (double*)LAPACKE_malloc( sizeof(double) * MAX(1,7*n) );
    if( work == NULL ) {
        info = LAPACK_WORK_MEMORY_ERROR;
        goto exit_level_1;
    }
    /* Call middle-level interface */
    info = LAPACKE_dsbevx_work( matrix_layout, jobz, range, uplo, n, kd, ab,
                                ldab, q, ldq, vl, vu, il, iu, abstol, m, w, z,
                                ldz, work, iwork, ifail );
    /* 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_dsbevx", info );
    }
    return info;
}
Ejemplo n.º 3
0
lapack_int LAPACKE_dsbgst( int matrix_layout, char vect, char uplo, lapack_int n,
                           lapack_int ka, lapack_int kb, double* ab,
                           lapack_int ldab, const double* bb, lapack_int ldbb,
                           double* x, lapack_int ldx )
{
    lapack_int info = 0;
    double* work = NULL;
    if( matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR ) {
        LAPACKE_xerbla( "LAPACKE_dsbgst", -1 );
        return -1;
    }
#ifndef LAPACK_DISABLE_NAN_CHECK
    /* Optionally check input matrices for NaNs */
    if( LAPACKE_dsb_nancheck( matrix_layout, uplo, n, ka, ab, ldab ) ) {
        return -7;
    }
    if( LAPACKE_dsb_nancheck( matrix_layout, uplo, n, kb, bb, ldbb ) ) {
        return -9;
    }
#endif
    /* Allocate memory for working array(s) */
    work = (double*)LAPACKE_malloc( sizeof(double) * MAX(1,2*n) );
    if( work == NULL ) {
        info = LAPACK_WORK_MEMORY_ERROR;
        goto exit_level_0;
    }
    /* Call middle-level interface */
    info = LAPACKE_dsbgst_work( matrix_layout, vect, uplo, n, ka, kb, ab, ldab,
                                bb, ldbb, x, ldx, work );
    /* Release memory and exit */
    LAPACKE_free( work );
exit_level_0:
    if( info == LAPACK_WORK_MEMORY_ERROR ) {
        LAPACKE_xerbla( "LAPACKE_dsbgst", info );
    }
    return info;
}
Ejemplo n.º 4
0
lapack_int LAPACKE_dsbev_2stage( int matrix_layout, char jobz, char uplo, lapack_int n,
                          lapack_int kd, double* ab, lapack_int ldab, double* w,
                          double* z, lapack_int ldz )
{
    lapack_int info = 0;
    lapack_int lwork = -1;
    double* work = NULL;
    double work_query;
    if( matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR ) {
        LAPACKE_xerbla( "LAPACKE_dsbev_2stage", -1 );
        return -1;
    }
#ifndef LAPACK_DISABLE_NAN_CHECK
    /* Optionally check input matrices for NaNs */
    if( LAPACKE_dsb_nancheck( matrix_layout, uplo, n, kd, ab, ldab ) ) {
        return -6;
    }
#endif
    /* Query optimal working array(s) size */
    info = LAPACKE_dsbev_2stage_work( matrix_layout, jobz, uplo, n, kd, ab, ldab, w, z,
                               ldz, &work_query, lwork );
    if( info != 0 ) {
        goto exit_level_0;
    }
    lwork = (lapack_int)work_query;
    /* Allocate memory for working array(s) */
    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_dsbev_2stage_work( matrix_layout, jobz, uplo, n, kd, ab, ldab, w, z,
                               ldz, work, lwork );
    /* Release memory and exit */
    LAPACKE_free( work );
exit_level_0:
    if( info == LAPACK_WORK_MEMORY_ERROR ) {
        LAPACKE_xerbla( "LAPACKE_dsbev_2stage", info );
    }
    return info;
}
Ejemplo n.º 5
0
lapack_int LAPACKE_dlascl( int matrix_layout, char type, lapack_int kl,
                           lapack_int ku, double cfrom, double cto,
                           lapack_int m, lapack_int n, double* a,
                           lapack_int lda )
{
    if( matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR ) {
        LAPACKE_xerbla( "LAPACKE_dlascl", -1 );
        return -1;
    }
#ifndef LAPACK_DISABLE_NAN_CHECK
    /* Optionally check input matrices for NaNs */
    switch (type) {
    case 'G':
        if( LAPACKE_dge_nancheck( matrix_layout, m, n, a, lda ) ) {
            return -9;
        }
        break;
    case 'L':
        // TYPE = 'L' - lower triangle of general matrix
        if( matrix_layout == LAPACK_COL_MAJOR &&
            LAPACKE_dgb_nancheck( matrix_layout, m, n, m-1, 0, a, lda+1 ) ) {
            return -9;
        }
        if( matrix_layout == LAPACK_ROW_MAJOR &&
            LAPACKE_dgb_nancheck( LAPACK_COL_MAJOR, n, m, 0, m-1, a-m+1, lda+1 ) ) {
            return -9;
        }
        break;
    case 'U':
        // TYPE = 'U' - upper triangle of general matrix
        if( matrix_layout == LAPACK_COL_MAJOR &&
            LAPACKE_dgb_nancheck( matrix_layout, m, n, 0, n-1, a-n+1, lda+1 ) ) {
            return -9;
        }
        if( matrix_layout == LAPACK_ROW_MAJOR &&
            LAPACKE_dgb_nancheck( LAPACK_COL_MAJOR, n, m, n-1, 0, a, lda+1 ) ) {
            return -9;
        }
        break;
    case 'H':
        // TYPE = 'H' - part of upper Hessenberg matrix in general matrix
        if( matrix_layout == LAPACK_COL_MAJOR &&
            LAPACKE_dgb_nancheck( matrix_layout, m, n, 1, n-1, a-n+1, lda+1 ) ) {
            return -9;
        }
        if( matrix_layout == LAPACK_ROW_MAJOR &&
            LAPACKE_dgb_nancheck( LAPACK_COL_MAJOR, n, m, n-1, 1, a-1, lda+1 ) ) {
            return -9;
        }
    case 'B':
        // TYPE = 'B' - lower part of symmetric band matrix (assume m==n)
        if( LAPACKE_dsb_nancheck( matrix_layout, 'L', n, kl, a, lda ) ) {
            return -9;
        }
        break;
    case 'Q':
        // TYPE = 'Q' - upper part of symmetric band matrix (assume m==n)
        if( LAPACKE_dsb_nancheck( matrix_layout, 'U', n, ku, a, lda ) ) {
            return -9;
        }
        break;
    case 'Z':
        // TYPE = 'Z' -  band matrix laid out for ?GBTRF
        if( matrix_layout == LAPACK_COL_MAJOR &&
            LAPACKE_dgb_nancheck( matrix_layout, m, n, kl, ku, a+kl, lda ) ) {
            return -9;
        }
        if( matrix_layout == LAPACK_ROW_MAJOR &&
            LAPACKE_dgb_nancheck( matrix_layout, m, n, kl, ku, a+lda*kl, lda ) ) {
            return -9;
        }
        break;
    }
#endif
    return LAPACKE_dlascl_work( matrix_layout, type, kl, ku, cfrom, cto, m,  n, a, lda );
}