lapack_int LAPACKE_zpbcon( int matrix_layout, char uplo, lapack_int n, lapack_int kd, const lapack_complex_double* ab, lapack_int ldab, double anorm, double* rcond ) { 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_zpbcon", -1 ); return -1; } #ifndef LAPACK_DISABLE_NAN_CHECK if( LAPACKE_get_nancheck() ) { /* Optionally check input matrices for NaNs */ if( LAPACKE_zpb_nancheck( matrix_layout, uplo, n, kd, ab, ldab ) ) { return -5; } if( LAPACKE_d_nancheck( 1, &anorm, 1 ) ) { return -7; } } #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_zpbcon_work( matrix_layout, uplo, n, kd, ab, ldab, anorm, 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_zpbcon", info ); } return info; }
int main(void) { /* Local scalars */ char uplo, uplo_i; lapack_int n, n_i; lapack_int kd, kd_i; lapack_int ldab, ldab_i; lapack_int ldab_r; double anorm, anorm_i; double rcond, rcond_i; lapack_int info, info_i; lapack_int i; int failed; /* Local arrays */ lapack_complex_double *ab = NULL, *ab_i = NULL; lapack_complex_double *work = NULL, *work_i = NULL; double *rwork = NULL, *rwork_i = NULL; lapack_complex_double *ab_r = NULL; /* Iniitialize the scalar parameters */ init_scalars_zpbcon( &uplo, &n, &kd, &ldab, &anorm ); ldab_r = n+2; uplo_i = uplo; n_i = n; kd_i = kd; ldab_i = ldab; anorm_i = anorm; /* Allocate memory for the LAPACK routine arrays */ ab = (lapack_complex_double *) LAPACKE_malloc( ldab*n * sizeof(lapack_complex_double) ); work = (lapack_complex_double *) LAPACKE_malloc( 2*n * sizeof(lapack_complex_double) ); rwork = (double *)LAPACKE_malloc( n * sizeof(double) ); /* Allocate memory for the C interface function arrays */ ab_i = (lapack_complex_double *) LAPACKE_malloc( ldab*n * sizeof(lapack_complex_double) ); work_i = (lapack_complex_double *) LAPACKE_malloc( 2*n * sizeof(lapack_complex_double) ); rwork_i = (double *)LAPACKE_malloc( n * sizeof(double) ); /* Allocate memory for the row-major arrays */ ab_r = (lapack_complex_double *) LAPACKE_malloc( (kd+1)*(n+2) * sizeof(lapack_complex_double) ); /* Initialize input arrays */ init_ab( ldab*n, ab ); init_work( 2*n, work ); init_rwork( n, rwork ); /* Call the LAPACK routine */ zpbcon_( &uplo, &n, &kd, ab, &ldab, &anorm, &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_zpbcon_work( LAPACK_COL_MAJOR, uplo_i, n_i, kd_i, ab_i, ldab_i, anorm_i, &rcond_i, work_i, rwork_i ); failed = compare_zpbcon( rcond, rcond_i, info, info_i ); if( failed == 0 ) { printf( "PASSED: column-major middle-level interface to zpbcon\n" ); } else { printf( "FAILED: column-major middle-level interface to zpbcon\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_zpbcon( LAPACK_COL_MAJOR, uplo_i, n_i, kd_i, ab_i, ldab_i, anorm_i, &rcond_i ); failed = compare_zpbcon( rcond, rcond_i, info, info_i ); if( failed == 0 ) { printf( "PASSED: column-major high-level interface to zpbcon\n" ); } else { printf( "FAILED: column-major high-level interface to zpbcon\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_zge_trans( LAPACK_COL_MAJOR, kd+1, n, ab_i, ldab, ab_r, n+2 ); info_i = LAPACKE_zpbcon_work( LAPACK_ROW_MAJOR, uplo_i, n_i, kd_i, ab_r, ldab_r, anorm_i, &rcond_i, work_i, rwork_i ); failed = compare_zpbcon( rcond, rcond_i, info, info_i ); if( failed == 0 ) { printf( "PASSED: row-major middle-level interface to zpbcon\n" ); } else { printf( "FAILED: row-major middle-level interface to zpbcon\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_zge_trans( LAPACK_COL_MAJOR, kd+1, n, ab_i, ldab, ab_r, n+2 ); info_i = LAPACKE_zpbcon( LAPACK_ROW_MAJOR, uplo_i, n_i, kd_i, ab_r, ldab_r, anorm_i, &rcond_i ); failed = compare_zpbcon( rcond, rcond_i, info, info_i ); if( failed == 0 ) { printf( "PASSED: row-major high-level interface to zpbcon\n" ); } else { printf( "FAILED: row-major high-level interface to zpbcon\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; }