lapack_int LAPACKE_cpptrs_work( int matrix_order, char uplo, lapack_int n, lapack_int nrhs, const lapack_complex_float* ap, lapack_complex_float* b, lapack_int ldb ) { lapack_int info = 0; if( matrix_order == LAPACK_COL_MAJOR ) { /* Call LAPACK function and adjust info */ LAPACK_cpptrs( &uplo, &n, &nrhs, ap, b, &ldb, &info ); if( info < 0 ) { info = info - 1; } } else if( matrix_order == LAPACK_ROW_MAJOR ) { lapack_int ldb_t = MAX(1,n); lapack_complex_float* b_t = NULL; lapack_complex_float* ap_t = NULL; /* Check leading dimension(s) */ if( ldb < nrhs ) { info = -7; LAPACKE_xerbla( "LAPACKE_cpptrs_work", info ); return info; } /* Allocate memory for temporary array(s) */ 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_0; } ap_t = (lapack_complex_float*) LAPACKE_malloc( sizeof(lapack_complex_float) * ( MAX(1,n) * MAX(2,n+1) ) / 2 ); if( ap_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_1; } /* Transpose input matrices */ LAPACKE_cge_trans( matrix_order, n, nrhs, b, ldb, b_t, ldb_t ); LAPACKE_cpp_trans( matrix_order, uplo, n, ap, ap_t ); /* Call LAPACK function and adjust info */ LAPACK_cpptrs( &uplo, &n, &nrhs, ap_t, b_t, &ldb_t, &info ); if( info < 0 ) { info = info - 1; } /* Transpose output matrices */ LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, nrhs, b_t, ldb_t, b, ldb ); /* Release memory and exit */ LAPACKE_free( ap_t ); exit_level_1: LAPACKE_free( b_t ); exit_level_0: if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_cpptrs_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_cpptrs_work", info ); } return info; }
lapack_int LAPACKE_cpptrf_work( int matrix_layout, char uplo, lapack_int n, lapack_complex_float* ap ) { lapack_int info = 0; if( matrix_layout == LAPACK_COL_MAJOR ) { /* Call LAPACK function and adjust info */ LAPACK_cpptrf( &uplo, &n, ap, &info ); if( info < 0 ) { info = info - 1; } } else if( matrix_layout == LAPACK_ROW_MAJOR ) { lapack_complex_float* ap_t = NULL; /* Allocate memory for temporary array(s) */ ap_t = (lapack_complex_float*) LAPACKE_malloc( sizeof(lapack_complex_float) * ( MAX(1,n) * MAX(2,n+1) ) / 2 ); if( ap_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_0; } /* Transpose input matrices */ LAPACKE_cpp_trans( matrix_layout, uplo, n, ap, ap_t ); /* Call LAPACK function and adjust info */ LAPACK_cpptrf( &uplo, &n, ap_t, &info ); if( info < 0 ) { info = info - 1; } /* Transpose output matrices */ LAPACKE_cpp_trans( LAPACK_COL_MAJOR, uplo, n, ap_t, ap ); /* Release memory and exit */ LAPACKE_free( ap_t ); exit_level_0: if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_cpptrf_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_cpptrf_work", info ); } return info; }
int main(void) { /* Local scalars */ char uplo, uplo_i; lapack_int n, n_i; lapack_int info, info_i; lapack_int i; int failed; /* Local arrays */ lapack_complex_float *ap = NULL, *ap_i = NULL; lapack_int *ipiv = NULL, *ipiv_i = NULL; lapack_complex_float *work = NULL, *work_i = NULL; lapack_complex_float *ap_save = NULL; lapack_complex_float *ap_r = NULL; /* Iniitialize the scalar parameters */ init_scalars_csptri( &uplo, &n ); uplo_i = uplo; n_i = n; /* Allocate memory for the LAPACK routine arrays */ ap = (lapack_complex_float *) LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_float) ); ipiv = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) ); work = (lapack_complex_float *) LAPACKE_malloc( n * sizeof(lapack_complex_float) ); /* Allocate memory for the C interface function arrays */ ap_i = (lapack_complex_float *) LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_float) ); ipiv_i = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) ); work_i = (lapack_complex_float *) LAPACKE_malloc( n * sizeof(lapack_complex_float) ); /* Allocate memory for the backup arrays */ ap_save = (lapack_complex_float *) LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_float) ); /* Allocate memory for the row-major arrays */ ap_r = (lapack_complex_float *) LAPACKE_malloc( n*(n+1)/2 * sizeof(lapack_complex_float) ); /* Initialize input arrays */ init_ap( (n*(n+1)/2), ap ); init_ipiv( n, ipiv ); init_work( n, work ); /* Backup the ouptut arrays */ for( i = 0; i < (n*(n+1)/2); i++ ) { ap_save[i] = ap[i]; } /* Call the LAPACK routine */ csptri_( &uplo, &n, ap, ipiv, work, &info ); /* Initialize input data, call the column-major middle-level * interface to LAPACK routine and check the results */ for( i = 0; i < (n*(n+1)/2); i++ ) { ap_i[i] = ap_save[i]; } for( i = 0; i < n; i++ ) { ipiv_i[i] = ipiv[i]; } for( i = 0; i < n; i++ ) { work_i[i] = work[i]; } info_i = LAPACKE_csptri_work( LAPACK_COL_MAJOR, uplo_i, n_i, ap_i, ipiv_i, work_i ); failed = compare_csptri( ap, ap_i, info, info_i, n ); if( failed == 0 ) { printf( "PASSED: column-major middle-level interface to csptri\n" ); } else { printf( "FAILED: column-major middle-level interface to csptri\n" ); } /* Initialize input data, call the column-major high-level * interface to LAPACK routine and check the results */ for( i = 0; i < (n*(n+1)/2); i++ ) { ap_i[i] = ap_save[i]; } for( i = 0; i < n; i++ ) { ipiv_i[i] = ipiv[i]; } for( i = 0; i < n; i++ ) { work_i[i] = work[i]; } info_i = LAPACKE_csptri( LAPACK_COL_MAJOR, uplo_i, n_i, ap_i, ipiv_i ); failed = compare_csptri( ap, ap_i, info, info_i, n ); if( failed == 0 ) { printf( "PASSED: column-major high-level interface to csptri\n" ); } else { printf( "FAILED: column-major high-level interface to csptri\n" ); } /* Initialize input data, call the row-major middle-level * interface to LAPACK routine and check the results */ for( i = 0; i < (n*(n+1)/2); i++ ) { ap_i[i] = ap_save[i]; } for( i = 0; i < n; i++ ) { ipiv_i[i] = ipiv[i]; } for( i = 0; i < n; i++ ) { work_i[i] = work[i]; } LAPACKE_cpp_trans( LAPACK_COL_MAJOR, uplo, n, ap_i, ap_r ); info_i = LAPACKE_csptri_work( LAPACK_ROW_MAJOR, uplo_i, n_i, ap_r, ipiv_i, work_i ); LAPACKE_cpp_trans( LAPACK_ROW_MAJOR, uplo, n, ap_r, ap_i ); failed = compare_csptri( ap, ap_i, info, info_i, n ); if( failed == 0 ) { printf( "PASSED: row-major middle-level interface to csptri\n" ); } else { printf( "FAILED: row-major middle-level interface to csptri\n" ); } /* Initialize input data, call the row-major high-level * interface to LAPACK routine and check the results */ for( i = 0; i < (n*(n+1)/2); i++ ) { ap_i[i] = ap_save[i]; } for( i = 0; i < n; i++ ) { ipiv_i[i] = ipiv[i]; } for( i = 0; i < n; i++ ) { work_i[i] = work[i]; } /* Init row_major arrays */ LAPACKE_cpp_trans( LAPACK_COL_MAJOR, uplo, n, ap_i, ap_r ); info_i = LAPACKE_csptri( LAPACK_ROW_MAJOR, uplo_i, n_i, ap_r, ipiv_i ); LAPACKE_cpp_trans( LAPACK_ROW_MAJOR, uplo, n, ap_r, ap_i ); failed = compare_csptri( ap, ap_i, info, info_i, n ); if( failed == 0 ) { printf( "PASSED: row-major high-level interface to csptri\n" ); } else { printf( "FAILED: row-major high-level interface to csptri\n" ); } /* Release memory */ if( ap != NULL ) { LAPACKE_free( ap ); } if( ap_i != NULL ) { LAPACKE_free( ap_i ); } if( ap_r != NULL ) { LAPACKE_free( ap_r ); } if( ap_save != NULL ) { LAPACKE_free( ap_save ); } 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; }
int main(void) { /* Local scalars */ char side, side_i; char uplo, uplo_i; char trans, trans_i; lapack_int m, m_i; lapack_int n, n_i; lapack_int ldc, ldc_i; lapack_int ldc_r; lapack_int info, info_i; /* Declare scalars */ lapack_int lwork; lapack_int i; int failed; /* Local arrays */ lapack_complex_float *ap = NULL, *ap_i = NULL; lapack_complex_float *tau = NULL, *tau_i = NULL; lapack_complex_float *c = NULL, *c_i = NULL; lapack_complex_float *work = NULL, *work_i = NULL; lapack_complex_float *c_save = NULL; lapack_complex_float *ap_r = NULL; lapack_complex_float *c_r = NULL; /* Iniitialize the scalar parameters */ init_scalars_cupmtr( &side, &uplo, &trans, &m, &n, &ldc ); lwork = MAX(m,n); ldc_r = n+2; side_i = side; uplo_i = uplo; trans_i = trans; m_i = m; n_i = n; ldc_i = ldc; /* Allocate memory for the LAPACK routine arrays */ ap = (lapack_complex_float *) LAPACKE_malloc( ((m*(m+1)/2)) * sizeof(lapack_complex_float) ); tau = (lapack_complex_float *) LAPACKE_malloc( (m-1) * sizeof(lapack_complex_float) ); c = (lapack_complex_float *) LAPACKE_malloc( ldc*n * sizeof(lapack_complex_float) ); work = (lapack_complex_float *) LAPACKE_malloc( lwork * sizeof(lapack_complex_float) ); /* Allocate memory for the C interface function arrays */ ap_i = (lapack_complex_float *) LAPACKE_malloc( ((m*(m+1)/2)) * sizeof(lapack_complex_float) ); tau_i = (lapack_complex_float *) LAPACKE_malloc( (m-1) * sizeof(lapack_complex_float) ); c_i = (lapack_complex_float *) LAPACKE_malloc( ldc*n * sizeof(lapack_complex_float) ); work_i = (lapack_complex_float *) LAPACKE_malloc( lwork * sizeof(lapack_complex_float) ); /* Allocate memory for the backup arrays */ c_save = (lapack_complex_float *) LAPACKE_malloc( ldc*n * sizeof(lapack_complex_float) ); /* Allocate memory for the row-major arrays */ ap_r = (lapack_complex_float *) LAPACKE_malloc( m*(m+1)/2 * sizeof(lapack_complex_float) ); c_r = (lapack_complex_float *) LAPACKE_malloc( m*(n+2) * sizeof(lapack_complex_float) ); /* Initialize input arrays */ init_ap( (m*(m+1)/2), ap ); init_tau( (m-1), tau ); init_c( ldc*n, c ); init_work( lwork, work ); /* Backup the ouptut arrays */ for( i = 0; i < ldc*n; i++ ) { c_save[i] = c[i]; } /* Call the LAPACK routine */ cupmtr_( &side, &uplo, &trans, &m, &n, ap, tau, c, &ldc, work, &info ); /* Initialize input data, call the column-major middle-level * interface to LAPACK routine and check the results */ for( i = 0; i < (m*(m+1)/2); i++ ) { ap_i[i] = ap[i]; } for( i = 0; i < (m-1); i++ ) { tau_i[i] = tau[i]; } for( i = 0; i < ldc*n; i++ ) { c_i[i] = c_save[i]; } for( i = 0; i < lwork; i++ ) { work_i[i] = work[i]; } info_i = LAPACKE_cupmtr_work( LAPACK_COL_MAJOR, side_i, uplo_i, trans_i, m_i, n_i, ap_i, tau_i, c_i, ldc_i, work_i ); failed = compare_cupmtr( c, c_i, info, info_i, ldc, n ); if( failed == 0 ) { printf( "PASSED: column-major middle-level interface to cupmtr\n" ); } else { printf( "FAILED: column-major middle-level interface to cupmtr\n" ); } /* Initialize input data, call the column-major high-level * interface to LAPACK routine and check the results */ for( i = 0; i < (m*(m+1)/2); i++ ) { ap_i[i] = ap[i]; } for( i = 0; i < (m-1); i++ ) { tau_i[i] = tau[i]; } for( i = 0; i < ldc*n; i++ ) { c_i[i] = c_save[i]; } for( i = 0; i < lwork; i++ ) { work_i[i] = work[i]; } info_i = LAPACKE_cupmtr( LAPACK_COL_MAJOR, side_i, uplo_i, trans_i, m_i, n_i, ap_i, tau_i, c_i, ldc_i ); failed = compare_cupmtr( c, c_i, info, info_i, ldc, n ); if( failed == 0 ) { printf( "PASSED: column-major high-level interface to cupmtr\n" ); } else { printf( "FAILED: column-major high-level interface to cupmtr\n" ); } /* Initialize input data, call the row-major middle-level * interface to LAPACK routine and check the results */ for( i = 0; i < (m*(m+1)/2); i++ ) { ap_i[i] = ap[i]; } for( i = 0; i < (m-1); i++ ) { tau_i[i] = tau[i]; } for( i = 0; i < ldc*n; i++ ) { c_i[i] = c_save[i]; } for( i = 0; i < lwork; i++ ) { work_i[i] = work[i]; } LAPACKE_cpp_trans( LAPACK_COL_MAJOR, uplo, m, ap_i, ap_r ); LAPACKE_cge_trans( LAPACK_COL_MAJOR, m, n, c_i, ldc, c_r, n+2 ); info_i = LAPACKE_cupmtr_work( LAPACK_ROW_MAJOR, side_i, uplo_i, trans_i, m_i, n_i, ap_r, tau_i, c_r, ldc_r, work_i ); LAPACKE_cge_trans( LAPACK_ROW_MAJOR, m, n, c_r, n+2, c_i, ldc ); failed = compare_cupmtr( c, c_i, info, info_i, ldc, n ); if( failed == 0 ) { printf( "PASSED: row-major middle-level interface to cupmtr\n" ); } else { printf( "FAILED: row-major middle-level interface to cupmtr\n" ); } /* Initialize input data, call the row-major high-level * interface to LAPACK routine and check the results */ for( i = 0; i < (m*(m+1)/2); i++ ) { ap_i[i] = ap[i]; } for( i = 0; i < (m-1); i++ ) { tau_i[i] = tau[i]; } for( i = 0; i < ldc*n; i++ ) { c_i[i] = c_save[i]; } for( i = 0; i < lwork; i++ ) { work_i[i] = work[i]; } /* Init row_major arrays */ LAPACKE_cpp_trans( LAPACK_COL_MAJOR, uplo, m, ap_i, ap_r ); LAPACKE_cge_trans( LAPACK_COL_MAJOR, m, n, c_i, ldc, c_r, n+2 ); info_i = LAPACKE_cupmtr( LAPACK_ROW_MAJOR, side_i, uplo_i, trans_i, m_i, n_i, ap_r, tau_i, c_r, ldc_r ); LAPACKE_cge_trans( LAPACK_ROW_MAJOR, m, n, c_r, n+2, c_i, ldc ); failed = compare_cupmtr( c, c_i, info, info_i, ldc, n ); if( failed == 0 ) { printf( "PASSED: row-major high-level interface to cupmtr\n" ); } else { printf( "FAILED: row-major high-level interface to cupmtr\n" ); } /* Release memory */ if( ap != NULL ) { LAPACKE_free( ap ); } if( ap_i != NULL ) { LAPACKE_free( ap_i ); } if( ap_r != NULL ) { LAPACKE_free( ap_r ); } if( tau != NULL ) { LAPACKE_free( tau ); } if( tau_i != NULL ) { LAPACKE_free( tau_i ); } if( c != NULL ) { LAPACKE_free( c ); } if( c_i != NULL ) { LAPACKE_free( c_i ); } if( c_r != NULL ) { LAPACKE_free( c_r ); } if( c_save != NULL ) { LAPACKE_free( c_save ); } if( work != NULL ) { LAPACKE_free( work ); } if( work_i != NULL ) { LAPACKE_free( work_i ); } return 0; }
lapack_int LAPACKE_cupmtr_work( int matrix_order, char side, char uplo, char trans, lapack_int m, lapack_int n, const lapack_complex_float* ap, const lapack_complex_float* tau, lapack_complex_float* c, lapack_int ldc, lapack_complex_float* work ) { lapack_int info = 0; if( matrix_order == LAPACK_COL_MAJOR ) { /* Call LAPACK function and adjust info */ LAPACK_cupmtr( &side, &uplo, &trans, &m, &n, ap, tau, c, &ldc, work, &info ); if( info < 0 ) { info = info - 1; } } else if( matrix_order == LAPACK_ROW_MAJOR ) { lapack_int r = LAPACKE_lsame( side, 'l' ) ? m : n; lapack_int ldc_t = MAX(1,m); lapack_complex_float* c_t = NULL; lapack_complex_float* ap_t = NULL; /* Check leading dimension(s) */ if( ldc < n ) { info = -10; LAPACKE_xerbla( "LAPACKE_cupmtr_work", info ); return info; } /* Allocate memory for temporary array(s) */ 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_0; } ap_t = (lapack_complex_float*) LAPACKE_malloc( sizeof(lapack_complex_float) * ( MAX(1,r) * MAX(2,r+1) ) / 2 ); if( ap_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_1; } /* Transpose input matrices */ LAPACKE_cge_trans( matrix_order, m, n, c, ldc, c_t, ldc_t ); LAPACKE_cpp_trans( matrix_order, uplo, r, ap, ap_t ); /* Call LAPACK function and adjust info */ LAPACK_cupmtr( &side, &uplo, &trans, &m, &n, ap_t, tau, c_t, &ldc_t, work, &info ); if( info < 0 ) { info = info - 1; } /* Transpose output matrices */ LAPACKE_cge_trans( LAPACK_COL_MAJOR, m, n, c_t, ldc_t, c, ldc ); /* Release memory and exit */ LAPACKE_free( ap_t ); exit_level_1: LAPACKE_free( c_t ); exit_level_0: if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_cupmtr_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_cupmtr_work", info ); } return info; }
int main(void) { /* Local scalars */ char uplo, uplo_i; lapack_int n, n_i; lapack_int nrhs, nrhs_i; lapack_int ldb, ldb_i; lapack_int ldb_r; lapack_int info, info_i; lapack_int i; int failed; /* Local arrays */ lapack_complex_float *ap = NULL, *ap_i = NULL; lapack_complex_float *b = NULL, *b_i = NULL; lapack_complex_float *b_save = NULL; lapack_complex_float *ap_r = NULL; lapack_complex_float *b_r = NULL; /* Iniitialize the scalar parameters */ init_scalars_cpptrs( &uplo, &n, &nrhs, &ldb ); ldb_r = nrhs+2; uplo_i = uplo; n_i = n; nrhs_i = nrhs; ldb_i = ldb; /* Allocate memory for the LAPACK routine arrays */ ap = (lapack_complex_float *) LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_float) ); b = (lapack_complex_float *) LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_float) ); /* Allocate memory for the C interface function arrays */ ap_i = (lapack_complex_float *) LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_float) ); b_i = (lapack_complex_float *) LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_float) ); /* Allocate memory for the backup arrays */ b_save = (lapack_complex_float *) LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_float) ); /* Allocate memory for the row-major arrays */ ap_r = (lapack_complex_float *) LAPACKE_malloc( n*(n+1)/2 * sizeof(lapack_complex_float) ); b_r = (lapack_complex_float *) LAPACKE_malloc( n*(nrhs+2) * sizeof(lapack_complex_float) ); /* Initialize input arrays */ init_ap( (n*(n+1)/2), ap ); init_b( ldb*nrhs, b ); /* Backup the ouptut arrays */ for( i = 0; i < ldb*nrhs; i++ ) { b_save[i] = b[i]; } /* Call the LAPACK routine */ cpptrs_( &uplo, &n, &nrhs, ap, b, &ldb, &info ); /* Initialize input data, call the column-major middle-level * interface to LAPACK routine and check the results */ for( i = 0; i < (n*(n+1)/2); i++ ) { ap_i[i] = ap[i]; } for( i = 0; i < ldb*nrhs; i++ ) { b_i[i] = b_save[i]; } info_i = LAPACKE_cpptrs_work( LAPACK_COL_MAJOR, uplo_i, n_i, nrhs_i, ap_i, b_i, ldb_i ); failed = compare_cpptrs( b, b_i, info, info_i, ldb, nrhs ); if( failed == 0 ) { printf( "PASSED: column-major middle-level interface to cpptrs\n" ); } else { printf( "FAILED: column-major middle-level interface to cpptrs\n" ); } /* Initialize input data, call the column-major high-level * interface to LAPACK routine and check the results */ for( i = 0; i < (n*(n+1)/2); i++ ) { ap_i[i] = ap[i]; } for( i = 0; i < ldb*nrhs; i++ ) { b_i[i] = b_save[i]; } info_i = LAPACKE_cpptrs( LAPACK_COL_MAJOR, uplo_i, n_i, nrhs_i, ap_i, b_i, ldb_i ); failed = compare_cpptrs( b, b_i, info, info_i, ldb, nrhs ); if( failed == 0 ) { printf( "PASSED: column-major high-level interface to cpptrs\n" ); } else { printf( "FAILED: column-major high-level interface to cpptrs\n" ); } /* Initialize input data, call the row-major middle-level * interface to LAPACK routine and check the results */ for( i = 0; i < (n*(n+1)/2); i++ ) { ap_i[i] = ap[i]; } for( i = 0; i < ldb*nrhs; i++ ) { b_i[i] = b_save[i]; } LAPACKE_cpp_trans( LAPACK_COL_MAJOR, uplo, n, ap_i, ap_r ); LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 ); info_i = LAPACKE_cpptrs_work( LAPACK_ROW_MAJOR, uplo_i, n_i, nrhs_i, ap_r, b_r, ldb_r ); LAPACKE_cge_trans( LAPACK_ROW_MAJOR, n, nrhs, b_r, nrhs+2, b_i, ldb ); failed = compare_cpptrs( b, b_i, info, info_i, ldb, nrhs ); if( failed == 0 ) { printf( "PASSED: row-major middle-level interface to cpptrs\n" ); } else { printf( "FAILED: row-major middle-level interface to cpptrs\n" ); } /* Initialize input data, call the row-major high-level * interface to LAPACK routine and check the results */ for( i = 0; i < (n*(n+1)/2); i++ ) { ap_i[i] = ap[i]; } for( i = 0; i < ldb*nrhs; i++ ) { b_i[i] = b_save[i]; } /* Init row_major arrays */ LAPACKE_cpp_trans( LAPACK_COL_MAJOR, uplo, n, ap_i, ap_r ); LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 ); info_i = LAPACKE_cpptrs( LAPACK_ROW_MAJOR, uplo_i, n_i, nrhs_i, ap_r, b_r, ldb_r ); LAPACKE_cge_trans( LAPACK_ROW_MAJOR, n, nrhs, b_r, nrhs+2, b_i, ldb ); failed = compare_cpptrs( b, b_i, info, info_i, ldb, nrhs ); if( failed == 0 ) { printf( "PASSED: row-major high-level interface to cpptrs\n" ); } else { printf( "FAILED: row-major high-level interface to cpptrs\n" ); } /* Release memory */ if( ap != NULL ) { LAPACKE_free( ap ); } if( ap_i != NULL ) { LAPACKE_free( ap_i ); } if( ap_r != NULL ) { LAPACKE_free( ap_r ); } if( b != NULL ) { LAPACKE_free( b ); } if( b_i != NULL ) { LAPACKE_free( b_i ); } if( b_r != NULL ) { LAPACKE_free( b_r ); } if( b_save != NULL ) { LAPACKE_free( b_save ); } return 0; }
int main(void) { /* Local scalars */ char uplo, uplo_i; lapack_int n, n_i; lapack_int nrhs, nrhs_i; lapack_int ldb, ldb_i; lapack_int ldb_r; lapack_int ldx, ldx_i; lapack_int ldx_r; lapack_int info, info_i; lapack_int i; int failed; /* Local arrays */ lapack_complex_float *ap = NULL, *ap_i = NULL; lapack_complex_float *afp = NULL, *afp_i = NULL; lapack_int *ipiv = NULL, *ipiv_i = NULL; lapack_complex_float *b = NULL, *b_i = NULL; lapack_complex_float *x = NULL, *x_i = NULL; float *ferr = NULL, *ferr_i = NULL; float *berr = NULL, *berr_i = NULL; lapack_complex_float *work = NULL, *work_i = NULL; float *rwork = NULL, *rwork_i = NULL; lapack_complex_float *x_save = NULL; float *ferr_save = NULL; float *berr_save = NULL; lapack_complex_float *ap_r = NULL; lapack_complex_float *afp_r = NULL; lapack_complex_float *b_r = NULL; lapack_complex_float *x_r = NULL; /* Iniitialize the scalar parameters */ init_scalars_csprfs( &uplo, &n, &nrhs, &ldb, &ldx ); ldb_r = nrhs+2; ldx_r = nrhs+2; uplo_i = uplo; n_i = n; nrhs_i = nrhs; ldb_i = ldb; ldx_i = ldx; /* Allocate memory for the LAPACK routine arrays */ ap = (lapack_complex_float *) LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_float) ); afp = (lapack_complex_float *) LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_float) ); ipiv = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) ); b = (lapack_complex_float *) LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_float) ); x = (lapack_complex_float *) LAPACKE_malloc( ldx*nrhs * sizeof(lapack_complex_float) ); ferr = (float *)LAPACKE_malloc( nrhs * sizeof(float) ); berr = (float *)LAPACKE_malloc( nrhs * sizeof(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 */ ap_i = (lapack_complex_float *) LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_float) ); afp_i = (lapack_complex_float *) LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_float) ); ipiv_i = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) ); b_i = (lapack_complex_float *) LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_float) ); x_i = (lapack_complex_float *) LAPACKE_malloc( ldx*nrhs * sizeof(lapack_complex_float) ); ferr_i = (float *)LAPACKE_malloc( nrhs * sizeof(float) ); berr_i = (float *)LAPACKE_malloc( nrhs * sizeof(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 backup arrays */ x_save = (lapack_complex_float *) LAPACKE_malloc( ldx*nrhs * sizeof(lapack_complex_float) ); ferr_save = (float *)LAPACKE_malloc( nrhs * sizeof(float) ); berr_save = (float *)LAPACKE_malloc( nrhs * sizeof(float) ); /* Allocate memory for the row-major arrays */ ap_r = (lapack_complex_float *) LAPACKE_malloc( n*(n+1)/2 * sizeof(lapack_complex_float) ); afp_r = (lapack_complex_float *) LAPACKE_malloc( n*(n+1)/2 * sizeof(lapack_complex_float) ); b_r = (lapack_complex_float *) LAPACKE_malloc( n*(nrhs+2) * sizeof(lapack_complex_float) ); x_r = (lapack_complex_float *) LAPACKE_malloc( n*(nrhs+2) * sizeof(lapack_complex_float) ); /* Initialize input arrays */ init_ap( (n*(n+1)/2), ap ); init_afp( (n*(n+1)/2), afp ); init_ipiv( n, ipiv ); init_b( ldb*nrhs, b ); init_x( ldx*nrhs, x ); init_ferr( nrhs, ferr ); init_berr( nrhs, berr ); init_work( 2*n, work ); init_rwork( n, rwork ); /* Backup the ouptut arrays */ for( i = 0; i < ldx*nrhs; i++ ) { x_save[i] = x[i]; } for( i = 0; i < nrhs; i++ ) { ferr_save[i] = ferr[i]; } for( i = 0; i < nrhs; i++ ) { berr_save[i] = berr[i]; } /* Call the LAPACK routine */ csprfs_( &uplo, &n, &nrhs, ap, afp, ipiv, b, &ldb, x, &ldx, ferr, berr, work, rwork, &info ); /* Initialize input data, call the column-major middle-level * interface to LAPACK routine and check the results */ for( i = 0; i < (n*(n+1)/2); i++ ) { ap_i[i] = ap[i]; } for( i = 0; i < (n*(n+1)/2); i++ ) { afp_i[i] = afp[i]; } for( i = 0; i < n; i++ ) { ipiv_i[i] = ipiv[i]; } for( i = 0; i < ldb*nrhs; i++ ) { b_i[i] = b[i]; } for( i = 0; i < ldx*nrhs; i++ ) { x_i[i] = x_save[i]; } for( i = 0; i < nrhs; i++ ) { ferr_i[i] = ferr_save[i]; } for( i = 0; i < nrhs; i++ ) { berr_i[i] = berr_save[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_csprfs_work( LAPACK_COL_MAJOR, uplo_i, n_i, nrhs_i, ap_i, afp_i, ipiv_i, b_i, ldb_i, x_i, ldx_i, ferr_i, berr_i, work_i, rwork_i ); failed = compare_csprfs( x, x_i, ferr, ferr_i, berr, berr_i, info, info_i, ldx, nrhs ); if( failed == 0 ) { printf( "PASSED: column-major middle-level interface to csprfs\n" ); } else { printf( "FAILED: column-major middle-level interface to csprfs\n" ); } /* Initialize input data, call the column-major high-level * interface to LAPACK routine and check the results */ for( i = 0; i < (n*(n+1)/2); i++ ) { ap_i[i] = ap[i]; } for( i = 0; i < (n*(n+1)/2); i++ ) { afp_i[i] = afp[i]; } for( i = 0; i < n; i++ ) { ipiv_i[i] = ipiv[i]; } for( i = 0; i < ldb*nrhs; i++ ) { b_i[i] = b[i]; } for( i = 0; i < ldx*nrhs; i++ ) { x_i[i] = x_save[i]; } for( i = 0; i < nrhs; i++ ) { ferr_i[i] = ferr_save[i]; } for( i = 0; i < nrhs; i++ ) { berr_i[i] = berr_save[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_csprfs( LAPACK_COL_MAJOR, uplo_i, n_i, nrhs_i, ap_i, afp_i, ipiv_i, b_i, ldb_i, x_i, ldx_i, ferr_i, berr_i ); failed = compare_csprfs( x, x_i, ferr, ferr_i, berr, berr_i, info, info_i, ldx, nrhs ); if( failed == 0 ) { printf( "PASSED: column-major high-level interface to csprfs\n" ); } else { printf( "FAILED: column-major high-level interface to csprfs\n" ); } /* Initialize input data, call the row-major middle-level * interface to LAPACK routine and check the results */ for( i = 0; i < (n*(n+1)/2); i++ ) { ap_i[i] = ap[i]; } for( i = 0; i < (n*(n+1)/2); i++ ) { afp_i[i] = afp[i]; } for( i = 0; i < n; i++ ) { ipiv_i[i] = ipiv[i]; } for( i = 0; i < ldb*nrhs; i++ ) { b_i[i] = b[i]; } for( i = 0; i < ldx*nrhs; i++ ) { x_i[i] = x_save[i]; } for( i = 0; i < nrhs; i++ ) { ferr_i[i] = ferr_save[i]; } for( i = 0; i < nrhs; i++ ) { berr_i[i] = berr_save[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_cpp_trans( LAPACK_COL_MAJOR, uplo, n, ap_i, ap_r ); LAPACKE_cpp_trans( LAPACK_COL_MAJOR, uplo, n, afp_i, afp_r ); LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 ); LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, nrhs, x_i, ldx, x_r, nrhs+2 ); info_i = LAPACKE_csprfs_work( LAPACK_ROW_MAJOR, uplo_i, n_i, nrhs_i, ap_r, afp_r, ipiv_i, b_r, ldb_r, x_r, ldx_r, ferr_i, berr_i, work_i, rwork_i ); LAPACKE_cge_trans( LAPACK_ROW_MAJOR, n, nrhs, x_r, nrhs+2, x_i, ldx ); failed = compare_csprfs( x, x_i, ferr, ferr_i, berr, berr_i, info, info_i, ldx, nrhs ); if( failed == 0 ) { printf( "PASSED: row-major middle-level interface to csprfs\n" ); } else { printf( "FAILED: row-major middle-level interface to csprfs\n" ); } /* Initialize input data, call the row-major high-level * interface to LAPACK routine and check the results */ for( i = 0; i < (n*(n+1)/2); i++ ) { ap_i[i] = ap[i]; } for( i = 0; i < (n*(n+1)/2); i++ ) { afp_i[i] = afp[i]; } for( i = 0; i < n; i++ ) { ipiv_i[i] = ipiv[i]; } for( i = 0; i < ldb*nrhs; i++ ) { b_i[i] = b[i]; } for( i = 0; i < ldx*nrhs; i++ ) { x_i[i] = x_save[i]; } for( i = 0; i < nrhs; i++ ) { ferr_i[i] = ferr_save[i]; } for( i = 0; i < nrhs; i++ ) { berr_i[i] = berr_save[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_cpp_trans( LAPACK_COL_MAJOR, uplo, n, ap_i, ap_r ); LAPACKE_cpp_trans( LAPACK_COL_MAJOR, uplo, n, afp_i, afp_r ); LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 ); LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, nrhs, x_i, ldx, x_r, nrhs+2 ); info_i = LAPACKE_csprfs( LAPACK_ROW_MAJOR, uplo_i, n_i, nrhs_i, ap_r, afp_r, ipiv_i, b_r, ldb_r, x_r, ldx_r, ferr_i, berr_i ); LAPACKE_cge_trans( LAPACK_ROW_MAJOR, n, nrhs, x_r, nrhs+2, x_i, ldx ); failed = compare_csprfs( x, x_i, ferr, ferr_i, berr, berr_i, info, info_i, ldx, nrhs ); if( failed == 0 ) { printf( "PASSED: row-major high-level interface to csprfs\n" ); } else { printf( "FAILED: row-major high-level interface to csprfs\n" ); } /* Release memory */ if( ap != NULL ) { LAPACKE_free( ap ); } if( ap_i != NULL ) { LAPACKE_free( ap_i ); } if( ap_r != NULL ) { LAPACKE_free( ap_r ); } if( afp != NULL ) { LAPACKE_free( afp ); } if( afp_i != NULL ) { LAPACKE_free( afp_i ); } if( afp_r != NULL ) { LAPACKE_free( afp_r ); } if( ipiv != NULL ) { LAPACKE_free( ipiv ); } if( ipiv_i != NULL ) { LAPACKE_free( ipiv_i ); } if( b != NULL ) { LAPACKE_free( b ); } if( b_i != NULL ) { LAPACKE_free( b_i ); } if( b_r != NULL ) { LAPACKE_free( b_r ); } if( x != NULL ) { LAPACKE_free( x ); } if( x_i != NULL ) { LAPACKE_free( x_i ); } if( x_r != NULL ) { LAPACKE_free( x_r ); } if( x_save != NULL ) { LAPACKE_free( x_save ); } if( ferr != NULL ) { LAPACKE_free( ferr ); } if( ferr_i != NULL ) { LAPACKE_free( ferr_i ); } if( ferr_save != NULL ) { LAPACKE_free( ferr_save ); } if( berr != NULL ) { LAPACKE_free( berr ); } if( berr_i != NULL ) { LAPACKE_free( berr_i ); } if( berr_save != NULL ) { LAPACKE_free( berr_save ); } 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; }