lapack_int LAPACKE_ctbcon( int matrix_layout, char norm, char uplo, char diag, lapack_int n, lapack_int kd, const lapack_complex_float* ab, lapack_int ldab, float* rcond ) { 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_ctbcon", -1 ); return -1; } #ifndef LAPACK_DISABLE_NAN_CHECK if( LAPACKE_get_nancheck() ) { /* Optionally check input matrices for NaNs */ if( LAPACKE_ctb_nancheck( matrix_layout, uplo, diag, n, kd, ab, ldab ) ) { return -7; } } #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_ctbcon_work( matrix_layout, norm, uplo, diag, n, kd, ab, ldab, rcond, 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_ctbcon", info ); } return info; }
int main(void) { /* Local scalars */ char norm, norm_i; char uplo, uplo_i; char diag, diag_i; lapack_int n, n_i; lapack_int kd, kd_i; lapack_int ldab, ldab_i; lapack_int ldab_r; float rcond, rcond_i; lapack_int info, info_i; lapack_int i; int failed; /* Local arrays */ lapack_complex_float *ab = NULL, *ab_i = NULL; lapack_complex_float *work = NULL, *work_i = NULL; float *rwork = NULL, *rwork_i = NULL; lapack_complex_float *ab_r = NULL; /* Iniitialize the scalar parameters */ init_scalars_ctbcon( &norm, &uplo, &diag, &n, &kd, &ldab ); ldab_r = n+2; norm_i = norm; uplo_i = uplo; diag_i = diag; n_i = n; kd_i = kd; ldab_i = ldab; /* Allocate memory for the LAPACK routine arrays */ ab = (lapack_complex_float *) LAPACKE_malloc( ldab*n * sizeof(lapack_complex_float) ); work = (lapack_complex_float *) LAPACKE_malloc( 2*n * sizeof(lapack_complex_float) ); rwork = (float *)LAPACKE_malloc( n * sizeof(float) ); /* Allocate memory for the C interface function arrays */ ab_i = (lapack_complex_float *) LAPACKE_malloc( ldab*n * sizeof(lapack_complex_float) ); work_i = (lapack_complex_float *) LAPACKE_malloc( 2*n * sizeof(lapack_complex_float) ); rwork_i = (float *)LAPACKE_malloc( n * sizeof(float) ); /* Allocate memory for the row-major arrays */ ab_r = (lapack_complex_float *) LAPACKE_malloc( (kd+1)*(n+2) * sizeof(lapack_complex_float) ); /* Initialize input arrays */ init_ab( ldab*n, ab ); init_work( 2*n, work ); init_rwork( n, rwork ); /* Call the LAPACK routine */ ctbcon_( &norm, &uplo, &diag, &n, &kd, ab, &ldab, &rcond, work, rwork, &info ); /* Initialize input data, call the column-major middle-level * interface to LAPACK routine and check the results */ for( i = 0; i < ldab*n; i++ ) { ab_i[i] = ab[i]; } for( i = 0; i < 2*n; i++ ) { work_i[i] = work[i]; } for( i = 0; i < n; i++ ) { rwork_i[i] = rwork[i]; } info_i = LAPACKE_ctbcon_work( LAPACK_COL_MAJOR, norm_i, uplo_i, diag_i, n_i, kd_i, ab_i, ldab_i, &rcond_i, work_i, rwork_i ); failed = compare_ctbcon( rcond, rcond_i, info, info_i ); if( failed == 0 ) { printf( "PASSED: column-major middle-level interface to ctbcon\n" ); } else { printf( "FAILED: column-major middle-level interface to ctbcon\n" ); } /* Initialize input data, call the column-major high-level * interface to LAPACK routine and check the results */ for( i = 0; i < ldab*n; i++ ) { ab_i[i] = ab[i]; } for( i = 0; i < 2*n; i++ ) { work_i[i] = work[i]; } for( i = 0; i < n; i++ ) { rwork_i[i] = rwork[i]; } info_i = LAPACKE_ctbcon( LAPACK_COL_MAJOR, norm_i, uplo_i, diag_i, n_i, kd_i, ab_i, ldab_i, &rcond_i ); failed = compare_ctbcon( rcond, rcond_i, info, info_i ); if( failed == 0 ) { printf( "PASSED: column-major high-level interface to ctbcon\n" ); } else { printf( "FAILED: column-major high-level interface to ctbcon\n" ); } /* Initialize input data, call the row-major middle-level * interface to LAPACK routine and check the results */ for( i = 0; i < ldab*n; i++ ) { ab_i[i] = ab[i]; } for( i = 0; i < 2*n; i++ ) { work_i[i] = work[i]; } for( i = 0; i < n; i++ ) { rwork_i[i] = rwork[i]; } LAPACKE_cge_trans( LAPACK_COL_MAJOR, kd+1, n, ab_i, ldab, ab_r, n+2 ); info_i = LAPACKE_ctbcon_work( LAPACK_ROW_MAJOR, norm_i, uplo_i, diag_i, n_i, kd_i, ab_r, ldab_r, &rcond_i, work_i, rwork_i ); failed = compare_ctbcon( rcond, rcond_i, info, info_i ); if( failed == 0 ) { printf( "PASSED: row-major middle-level interface to ctbcon\n" ); } else { printf( "FAILED: row-major middle-level interface to ctbcon\n" ); } /* Initialize input data, call the row-major high-level * interface to LAPACK routine and check the results */ for( i = 0; i < ldab*n; i++ ) { ab_i[i] = ab[i]; } for( i = 0; i < 2*n; i++ ) { work_i[i] = work[i]; } for( i = 0; i < n; i++ ) { rwork_i[i] = rwork[i]; } /* Init row_major arrays */ LAPACKE_cge_trans( LAPACK_COL_MAJOR, kd+1, n, ab_i, ldab, ab_r, n+2 ); info_i = LAPACKE_ctbcon( LAPACK_ROW_MAJOR, norm_i, uplo_i, diag_i, n_i, kd_i, ab_r, ldab_r, &rcond_i ); failed = compare_ctbcon( rcond, rcond_i, info, info_i ); if( failed == 0 ) { printf( "PASSED: row-major high-level interface to ctbcon\n" ); } else { printf( "FAILED: row-major high-level interface to ctbcon\n" ); } /* Release memory */ if( ab != NULL ) { LAPACKE_free( ab ); } if( ab_i != NULL ) { LAPACKE_free( ab_i ); } if( ab_r != NULL ) { LAPACKE_free( ab_r ); } if( work != NULL ) { LAPACKE_free( work ); } if( work_i != NULL ) { LAPACKE_free( work_i ); } if( rwork != NULL ) { LAPACKE_free( rwork ); } if( rwork_i != NULL ) { LAPACKE_free( rwork_i ); } return 0; }