lapack_int LAPACKE_checon( int matrix_layout, char uplo, lapack_int n, const lapack_complex_float* a, lapack_int lda, const lapack_int* ipiv, float anorm, float* rcond ) { lapack_int info = 0; lapack_complex_float* work = NULL; if( matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR ) { LAPACKE_xerbla( "LAPACKE_checon", -1 ); return -1; } #ifndef LAPACK_DISABLE_NAN_CHECK /* Optionally check input matrices for NaNs */ if( LAPACKE_che_nancheck( matrix_layout, uplo, n, a, lda ) ) { return -4; } if( LAPACKE_s_nancheck( 1, &anorm, 1 ) ) { return -7; } #endif /* Allocate memory for working array(s) */ 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_0; } /* Call middle-level interface */ info = LAPACKE_checon_work( matrix_layout, uplo, n, a, lda, ipiv, anorm, rcond, work ); /* Release memory and exit */ LAPACKE_free( work ); exit_level_0: if( info == LAPACK_WORK_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_checon", info ); } return info; }
int main(void) { /* Local scalars */ char uplo, uplo_i; lapack_int n, n_i; lapack_int lda, lda_i; lapack_int lda_r; float anorm, anorm_i; float rcond, rcond_i; lapack_int info, info_i; lapack_int i; int failed; /* Local arrays */ lapack_complex_float *a = NULL, *a_i = NULL; lapack_int *ipiv = NULL, *ipiv_i = NULL; lapack_complex_float *work = NULL, *work_i = NULL; lapack_complex_float *a_r = NULL; /* Iniitialize the scalar parameters */ init_scalars_checon( &uplo, &n, &lda, &anorm ); lda_r = n+2; uplo_i = uplo; n_i = n; lda_i = lda; anorm_i = anorm; /* Allocate memory for the LAPACK routine arrays */ a = (lapack_complex_float *) LAPACKE_malloc( lda*n * sizeof(lapack_complex_float) ); ipiv = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) ); work = (lapack_complex_float *) LAPACKE_malloc( 2*n * sizeof(lapack_complex_float) ); /* Allocate memory for the C interface function arrays */ a_i = (lapack_complex_float *) LAPACKE_malloc( lda*n * sizeof(lapack_complex_float) ); ipiv_i = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) ); work_i = (lapack_complex_float *) LAPACKE_malloc( 2*n * sizeof(lapack_complex_float) ); /* Allocate memory for the row-major arrays */ a_r = (lapack_complex_float *) LAPACKE_malloc( n*(n+2) * sizeof(lapack_complex_float) ); /* Initialize input arrays */ init_a( lda*n, a ); init_ipiv( n, ipiv ); init_work( 2*n, work ); /* Call the LAPACK routine */ checon_( &uplo, &n, a, &lda, ipiv, &anorm, &rcond, work, &info ); /* Initialize input data, call the column-major middle-level * interface to LAPACK routine and check the results */ for( i = 0; i < lda*n; i++ ) { a_i[i] = a[i]; } for( i = 0; i < n; i++ ) { ipiv_i[i] = ipiv[i]; } for( i = 0; i < 2*n; i++ ) { work_i[i] = work[i]; } info_i = LAPACKE_checon_work( LAPACK_COL_MAJOR, uplo_i, n_i, a_i, lda_i, ipiv_i, anorm_i, &rcond_i, work_i ); failed = compare_checon( rcond, rcond_i, info, info_i ); if( failed == 0 ) { printf( "PASSED: column-major middle-level interface to checon\n" ); } else { printf( "FAILED: column-major middle-level interface to checon\n" ); } /* Initialize input data, call the column-major high-level * interface to LAPACK routine and check the results */ for( i = 0; i < lda*n; i++ ) { a_i[i] = a[i]; } for( i = 0; i < n; i++ ) { ipiv_i[i] = ipiv[i]; } for( i = 0; i < 2*n; i++ ) { work_i[i] = work[i]; } info_i = LAPACKE_checon( LAPACK_COL_MAJOR, uplo_i, n_i, a_i, lda_i, ipiv_i, anorm_i, &rcond_i ); failed = compare_checon( rcond, rcond_i, info, info_i ); if( failed == 0 ) { printf( "PASSED: column-major high-level interface to checon\n" ); } else { printf( "FAILED: column-major high-level interface to checon\n" ); } /* Initialize input data, call the row-major middle-level * interface to LAPACK routine and check the results */ for( i = 0; i < lda*n; i++ ) { a_i[i] = a[i]; } for( i = 0; i < n; i++ ) { ipiv_i[i] = ipiv[i]; } for( i = 0; i < 2*n; i++ ) { work_i[i] = work[i]; } LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, a_i, lda, a_r, n+2 ); info_i = LAPACKE_checon_work( LAPACK_ROW_MAJOR, uplo_i, n_i, a_r, lda_r, ipiv_i, anorm_i, &rcond_i, work_i ); failed = compare_checon( rcond, rcond_i, info, info_i ); if( failed == 0 ) { printf( "PASSED: row-major middle-level interface to checon\n" ); } else { printf( "FAILED: row-major middle-level interface to checon\n" ); } /* Initialize input data, call the row-major high-level * interface to LAPACK routine and check the results */ for( i = 0; i < lda*n; i++ ) { a_i[i] = a[i]; } for( i = 0; i < n; i++ ) { ipiv_i[i] = ipiv[i]; } for( i = 0; i < 2*n; i++ ) { work_i[i] = work[i]; } /* Init row_major arrays */ LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, a_i, lda, a_r, n+2 ); info_i = LAPACKE_checon( LAPACK_ROW_MAJOR, uplo_i, n_i, a_r, lda_r, ipiv_i, anorm_i, &rcond_i ); failed = compare_checon( rcond, rcond_i, info, info_i ); if( failed == 0 ) { printf( "PASSED: row-major high-level interface to checon\n" ); } else { printf( "FAILED: row-major high-level interface to checon\n" ); } /* Release memory */ if( a != NULL ) { LAPACKE_free( a ); } if( a_i != NULL ) { LAPACKE_free( a_i ); } if( a_r != NULL ) { LAPACKE_free( a_r ); } if( ipiv != NULL ) { LAPACKE_free( ipiv ); } if( ipiv_i != NULL ) { LAPACKE_free( ipiv_i ); } if( work != NULL ) { LAPACKE_free( work ); } if( work_i != NULL ) { LAPACKE_free( work_i ); } return 0; }