lapack_int LAPACKE_zupgtr_work( int matrix_layout, char uplo, lapack_int n, const lapack_complex_double* ap, const lapack_complex_double* tau, lapack_complex_double* q, lapack_int ldq, lapack_complex_double* work ) { lapack_int info = 0; if( matrix_layout == LAPACK_COL_MAJOR ) { /* Call LAPACK function and adjust info */ LAPACK_zupgtr( &uplo, &n, ap, tau, q, &ldq, work, &info ); if( info < 0 ) { info = info - 1; } } else if( matrix_layout == LAPACK_ROW_MAJOR ) { lapack_int ldq_t = MAX(1,n); lapack_complex_double* q_t = NULL; lapack_complex_double* ap_t = NULL; /* Check leading dimension(s) */ if( ldq < n ) { info = -7; LAPACKE_xerbla( "LAPACKE_zupgtr_work", info ); return info; } /* Allocate memory for temporary array(s) */ q_t = (lapack_complex_double*) LAPACKE_malloc( sizeof(lapack_complex_double) * ldq_t * MAX(1,n) ); if( q_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_0; } ap_t = (lapack_complex_double*) LAPACKE_malloc( sizeof(lapack_complex_double) * ( 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_zpp_trans( matrix_layout, uplo, n, ap, ap_t ); /* Call LAPACK function and adjust info */ LAPACK_zupgtr( &uplo, &n, ap_t, tau, q_t, &ldq_t, work, &info ); if( info < 0 ) { info = info - 1; } /* Transpose output matrices */ LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, q_t, ldq_t, q, ldq ); /* Release memory and exit */ LAPACKE_free( ap_t ); exit_level_1: LAPACKE_free( q_t ); exit_level_0: if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_zupgtr_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_zupgtr_work", info ); } return info; }
lapack_int LAPACKE_zpptrf_work( int matrix_layout, char uplo, lapack_int n, lapack_complex_double* ap ) { lapack_int info = 0; if( matrix_layout == LAPACK_COL_MAJOR ) { /* Call LAPACK function and adjust info */ LAPACK_zpptrf( &uplo, &n, ap, &info ); if( info < 0 ) { info = info - 1; } } else if( matrix_layout == LAPACK_ROW_MAJOR ) { lapack_complex_double* ap_t = NULL; /* Allocate memory for temporary array(s) */ ap_t = (lapack_complex_double*) LAPACKE_malloc( sizeof(lapack_complex_double) * ( 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_zpp_trans( matrix_layout, uplo, n, ap, ap_t ); /* Call LAPACK function and adjust info */ LAPACK_zpptrf( &uplo, &n, ap_t, &info ); if( info < 0 ) { info = info - 1; } /* Transpose output matrices */ LAPACKE_zpp_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_zpptrf_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_zpptrf_work", info ); } return info; }
lapack_int LAPACKE_zupmtr_work( int matrix_layout, char side, char uplo, char trans, lapack_int m, lapack_int n, const lapack_complex_double* ap, const lapack_complex_double* tau, lapack_complex_double* c, lapack_int ldc, lapack_complex_double* work ) { lapack_int info = 0; if( matrix_layout == LAPACK_COL_MAJOR ) { /* Call LAPACK function and adjust info */ LAPACK_zupmtr( &side, &uplo, &trans, &m, &n, ap, tau, c, &ldc, work, &info ); if( info < 0 ) { info = info - 1; } } else if( matrix_layout == LAPACK_ROW_MAJOR ) { lapack_int r = LAPACKE_lsame( side, 'l' ) ? m : n; lapack_int ldc_t = MAX(1,m); lapack_complex_double* c_t = NULL; lapack_complex_double* ap_t = NULL; /* Check leading dimension(s) */ if( ldc < n ) { info = -10; LAPACKE_xerbla( "LAPACKE_zupmtr_work", info ); return info; } /* Allocate memory for temporary array(s) */ c_t = (lapack_complex_double*) LAPACKE_malloc( sizeof(lapack_complex_double) * ldc_t * MAX(1,n) ); if( c_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_0; } ap_t = (lapack_complex_double*) LAPACKE_malloc( sizeof(lapack_complex_double) * ( 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_zge_trans( matrix_layout, m, n, c, ldc, c_t, ldc_t ); LAPACKE_zpp_trans( matrix_layout, uplo, r, ap, ap_t ); /* Call LAPACK function and adjust info */ LAPACK_zupmtr( &side, &uplo, &trans, &m, &n, ap_t, tau, c_t, &ldc_t, work, &info ); if( info < 0 ) { info = info - 1; } /* Transpose output matrices */ LAPACKE_zge_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_zupmtr_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_zupmtr_work", info ); } return info; }
int main(void) { /* Local scalars */ char uplo, uplo_i; lapack_int n, n_i; double anorm, anorm_i; double rcond, rcond_i; lapack_int info, info_i; lapack_int i; int failed; /* Local arrays */ lapack_complex_double *ap = NULL, *ap_i = NULL; lapack_int *ipiv = NULL, *ipiv_i = NULL; lapack_complex_double *work = NULL, *work_i = NULL; lapack_complex_double *ap_r = NULL; /* Iniitialize the scalar parameters */ init_scalars_zhpcon( &uplo, &n, &anorm ); uplo_i = uplo; n_i = n; anorm_i = anorm; /* Allocate memory for the LAPACK routine arrays */ ap = (lapack_complex_double *) LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_double) ); ipiv = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) ); work = (lapack_complex_double *) LAPACKE_malloc( 2*n * sizeof(lapack_complex_double) ); /* Allocate memory for the C interface function arrays */ ap_i = (lapack_complex_double *) LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_double) ); ipiv_i = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) ); work_i = (lapack_complex_double *) LAPACKE_malloc( 2*n * sizeof(lapack_complex_double) ); /* Allocate memory for the row-major arrays */ ap_r = (lapack_complex_double *) LAPACKE_malloc( n*(n+1)/2 * sizeof(lapack_complex_double) ); /* Initialize input arrays */ init_ap( (n*(n+1)/2), ap ); init_ipiv( n, ipiv ); init_work( 2*n, work ); /* Call the LAPACK routine */ zhpcon_( &uplo, &n, ap, 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 < (n*(n+1)/2); i++ ) { ap_i[i] = ap[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_zhpcon_work( LAPACK_COL_MAJOR, uplo_i, n_i, ap_i, ipiv_i, anorm_i, &rcond_i, work_i ); failed = compare_zhpcon( rcond, rcond_i, info, info_i ); if( failed == 0 ) { printf( "PASSED: column-major middle-level interface to zhpcon\n" ); } else { printf( "FAILED: column-major middle-level interface to zhpcon\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; i++ ) { ipiv_i[i] = ipiv[i]; } for( i = 0; i < 2*n; i++ ) { work_i[i] = work[i]; } info_i = LAPACKE_zhpcon( LAPACK_COL_MAJOR, uplo_i, n_i, ap_i, ipiv_i, anorm_i, &rcond_i ); failed = compare_zhpcon( rcond, rcond_i, info, info_i ); if( failed == 0 ) { printf( "PASSED: column-major high-level interface to zhpcon\n" ); } else { printf( "FAILED: column-major high-level interface to zhpcon\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; i++ ) { ipiv_i[i] = ipiv[i]; } for( i = 0; i < 2*n; i++ ) { work_i[i] = work[i]; } LAPACKE_zpp_trans( LAPACK_COL_MAJOR, uplo, n, ap_i, ap_r ); info_i = LAPACKE_zhpcon_work( LAPACK_ROW_MAJOR, uplo_i, n_i, ap_r, ipiv_i, anorm_i, &rcond_i, work_i ); failed = compare_zhpcon( rcond, rcond_i, info, info_i ); if( failed == 0 ) { printf( "PASSED: row-major middle-level interface to zhpcon\n" ); } else { printf( "FAILED: row-major middle-level interface to zhpcon\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; i++ ) { ipiv_i[i] = ipiv[i]; } for( i = 0; i < 2*n; i++ ) { work_i[i] = work[i]; } /* Init row_major arrays */ LAPACKE_zpp_trans( LAPACK_COL_MAJOR, uplo, n, ap_i, ap_r ); info_i = LAPACKE_zhpcon( LAPACK_ROW_MAJOR, uplo_i, n_i, ap_r, ipiv_i, anorm_i, &rcond_i ); failed = compare_zhpcon( rcond, rcond_i, info, info_i ); if( failed == 0 ) { printf( "PASSED: row-major high-level interface to zhpcon\n" ); } else { printf( "FAILED: row-major high-level interface to zhpcon\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( 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; }
lapack_int LAPACKE_zppsv_work( int matrix_order, char uplo, lapack_int n, lapack_int nrhs, lapack_complex_double* ap, lapack_complex_double* b, lapack_int ldb ) { lapack_int info = 0; if( matrix_order == LAPACK_COL_MAJOR ) { /* Call LAPACK function and adjust info */ LAPACK_zppsv( &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_double* b_t = NULL; lapack_complex_double* ap_t = NULL; /* Check leading dimension(s) */ if( ldb < nrhs ) { info = -7; LAPACKE_xerbla( "LAPACKE_zppsv_work", info ); return info; } /* Allocate memory for temporary array(s) */ b_t = (lapack_complex_double*) LAPACKE_malloc( sizeof(lapack_complex_double) * ldb_t * MAX(1,nrhs) ); if( b_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_0; } ap_t = (lapack_complex_double*) LAPACKE_malloc( sizeof(lapack_complex_double) * ( 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_zge_trans( matrix_order, n, nrhs, b, ldb, b_t, ldb_t ); LAPACKE_zpp_trans( matrix_order, uplo, n, ap, ap_t ); /* Call LAPACK function and adjust info */ LAPACK_zppsv( &uplo, &n, &nrhs, ap_t, b_t, &ldb_t, &info ); if( info < 0 ) { info = info - 1; } /* Transpose output matrices */ LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, nrhs, b_t, ldb_t, b, ldb ); LAPACKE_zpp_trans( LAPACK_COL_MAJOR, uplo, n, ap_t, ap ); /* 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_zppsv_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_zppsv_work", info ); } return info; }
lapack_int LAPACKE_zppsvx_work( int matrix_order, char fact, char uplo, lapack_int n, lapack_int nrhs, lapack_complex_double* ap, lapack_complex_double* afp, char* equed, double* s, lapack_complex_double* b, lapack_int ldb, lapack_complex_double* x, lapack_int ldx, double* rcond, double* ferr, double* berr, lapack_complex_double* work, double* rwork ) { lapack_int info = 0; if( matrix_order == LAPACK_COL_MAJOR ) { /* Call LAPACK function and adjust info */ LAPACK_zppsvx( &fact, &uplo, &n, &nrhs, ap, afp, equed, s, b, &ldb, x, &ldx, rcond, ferr, berr, work, rwork, &info ); if( info < 0 ) { info = info - 1; } } else if( matrix_order == LAPACK_ROW_MAJOR ) { lapack_int ldb_t = MAX(1,n); lapack_int ldx_t = MAX(1,n); lapack_complex_double* b_t = NULL; lapack_complex_double* x_t = NULL; lapack_complex_double* ap_t = NULL; lapack_complex_double* afp_t = NULL; /* Check leading dimension(s) */ if( ldb < nrhs ) { info = -11; LAPACKE_xerbla( "LAPACKE_zppsvx_work", info ); return info; } if( ldx < nrhs ) { info = -13; LAPACKE_xerbla( "LAPACKE_zppsvx_work", info ); return info; } /* Allocate memory for temporary array(s) */ b_t = (lapack_complex_double*) LAPACKE_malloc( sizeof(lapack_complex_double) * ldb_t * MAX(1,nrhs) ); if( b_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_0; } x_t = (lapack_complex_double*) LAPACKE_malloc( sizeof(lapack_complex_double) * ldx_t * MAX(1,nrhs) ); if( x_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_1; } ap_t = (lapack_complex_double*) LAPACKE_malloc( sizeof(lapack_complex_double) * ( MAX(1,n) * MAX(2,n+1) ) / 2 ); if( ap_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_2; } afp_t = (lapack_complex_double*) LAPACKE_malloc( sizeof(lapack_complex_double) * ( MAX(1,n) * MAX(2,n+1) ) / 2 ); if( afp_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_3; } /* Transpose input matrices */ LAPACKE_zge_trans( matrix_order, n, nrhs, b, ldb, b_t, ldb_t ); LAPACKE_zpp_trans( matrix_order, uplo, n, ap, ap_t ); if( LAPACKE_lsame( fact, 'f' ) ) { LAPACKE_zpp_trans( matrix_order, uplo, n, afp, afp_t ); } /* Call LAPACK function and adjust info */ LAPACK_zppsvx( &fact, &uplo, &n, &nrhs, ap_t, afp_t, equed, s, b_t, &ldb_t, x_t, &ldx_t, rcond, ferr, berr, work, rwork, &info ); if( info < 0 ) { info = info - 1; } /* Transpose output matrices */ LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, nrhs, b_t, ldb_t, b, ldb ); LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, nrhs, x_t, ldx_t, x, ldx ); if( LAPACKE_lsame( fact, 'e' ) && LAPACKE_lsame( *equed, 'y' ) ) { LAPACKE_zpp_trans( LAPACK_COL_MAJOR, uplo, n, ap_t, ap ); } if( LAPACKE_lsame( fact, 'e' ) || LAPACKE_lsame( fact, 'n' ) ) { LAPACKE_zpp_trans( LAPACK_COL_MAJOR, uplo, n, afp_t, afp ); } /* Release memory and exit */ LAPACKE_free( afp_t ); exit_level_3: LAPACKE_free( ap_t ); exit_level_2: LAPACKE_free( x_t ); exit_level_1: LAPACKE_free( b_t ); exit_level_0: if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_zppsvx_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_zppsvx_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_double *ap = NULL, *ap_i = NULL; lapack_int *ipiv = NULL, *ipiv_i = NULL; lapack_complex_double *b = NULL, *b_i = NULL; lapack_complex_double *b_save = NULL; lapack_complex_double *ap_r = NULL; lapack_complex_double *b_r = NULL; /* Iniitialize the scalar parameters */ init_scalars_zhptrs( &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_double *) LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_double) ); ipiv = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) ); b = (lapack_complex_double *) LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_double) ); /* Allocate memory for the C interface function arrays */ ap_i = (lapack_complex_double *) LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_double) ); ipiv_i = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) ); b_i = (lapack_complex_double *) LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_double) ); /* Allocate memory for the backup arrays */ b_save = (lapack_complex_double *) LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_double) ); /* Allocate memory for the row-major arrays */ ap_r = (lapack_complex_double *) LAPACKE_malloc( n*(n+1)/2 * sizeof(lapack_complex_double) ); b_r = (lapack_complex_double *) LAPACKE_malloc( n*(nrhs+2) * sizeof(lapack_complex_double) ); /* Initialize input arrays */ init_ap( (n*(n+1)/2), ap ); init_ipiv( n, ipiv ); 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 */ zhptrs_( &uplo, &n, &nrhs, ap, ipiv, 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 < n; i++ ) { ipiv_i[i] = ipiv[i]; } for( i = 0; i < ldb*nrhs; i++ ) { b_i[i] = b_save[i]; } info_i = LAPACKE_zhptrs_work( LAPACK_COL_MAJOR, uplo_i, n_i, nrhs_i, ap_i, ipiv_i, b_i, ldb_i ); failed = compare_zhptrs( b, b_i, info, info_i, ldb, nrhs ); if( failed == 0 ) { printf( "PASSED: column-major middle-level interface to zhptrs\n" ); } else { printf( "FAILED: column-major middle-level interface to zhptrs\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; i++ ) { ipiv_i[i] = ipiv[i]; } for( i = 0; i < ldb*nrhs; i++ ) { b_i[i] = b_save[i]; } info_i = LAPACKE_zhptrs( LAPACK_COL_MAJOR, uplo_i, n_i, nrhs_i, ap_i, ipiv_i, b_i, ldb_i ); failed = compare_zhptrs( b, b_i, info, info_i, ldb, nrhs ); if( failed == 0 ) { printf( "PASSED: column-major high-level interface to zhptrs\n" ); } else { printf( "FAILED: column-major high-level interface to zhptrs\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; i++ ) { ipiv_i[i] = ipiv[i]; } for( i = 0; i < ldb*nrhs; i++ ) { b_i[i] = b_save[i]; } LAPACKE_zpp_trans( LAPACK_COL_MAJOR, uplo, n, ap_i, ap_r ); LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 ); info_i = LAPACKE_zhptrs_work( LAPACK_ROW_MAJOR, uplo_i, n_i, nrhs_i, ap_r, ipiv_i, b_r, ldb_r ); LAPACKE_zge_trans( LAPACK_ROW_MAJOR, n, nrhs, b_r, nrhs+2, b_i, ldb ); failed = compare_zhptrs( b, b_i, info, info_i, ldb, nrhs ); if( failed == 0 ) { printf( "PASSED: row-major middle-level interface to zhptrs\n" ); } else { printf( "FAILED: row-major middle-level interface to zhptrs\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; i++ ) { ipiv_i[i] = ipiv[i]; } for( i = 0; i < ldb*nrhs; i++ ) { b_i[i] = b_save[i]; } /* Init row_major arrays */ LAPACKE_zpp_trans( LAPACK_COL_MAJOR, uplo, n, ap_i, ap_r ); LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 ); info_i = LAPACKE_zhptrs( LAPACK_ROW_MAJOR, uplo_i, n_i, nrhs_i, ap_r, ipiv_i, b_r, ldb_r ); LAPACKE_zge_trans( LAPACK_ROW_MAJOR, n, nrhs, b_r, nrhs+2, b_i, ldb ); failed = compare_zhptrs( b, b_i, info, info_i, ldb, nrhs ); if( failed == 0 ) { printf( "PASSED: row-major high-level interface to zhptrs\n" ); } else { printf( "FAILED: row-major high-level interface to zhptrs\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( 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( b_save != NULL ) { LAPACKE_free( b_save ); } 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_double *ap = NULL, *ap_i = NULL; lapack_complex_double *tau = NULL, *tau_i = NULL; lapack_complex_double *c = NULL, *c_i = NULL; lapack_complex_double *work = NULL, *work_i = NULL; lapack_complex_double *c_save = NULL; lapack_complex_double *ap_r = NULL; lapack_complex_double *c_r = NULL; /* Iniitialize the scalar parameters */ init_scalars_zupmtr( &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_double *) LAPACKE_malloc( ((m*(m+1)/2)) * sizeof(lapack_complex_double) ); tau = (lapack_complex_double *) LAPACKE_malloc( (m-1) * sizeof(lapack_complex_double) ); c = (lapack_complex_double *) LAPACKE_malloc( ldc*n * sizeof(lapack_complex_double) ); work = (lapack_complex_double *) LAPACKE_malloc( lwork * sizeof(lapack_complex_double) ); /* Allocate memory for the C interface function arrays */ ap_i = (lapack_complex_double *) LAPACKE_malloc( ((m*(m+1)/2)) * sizeof(lapack_complex_double) ); tau_i = (lapack_complex_double *) LAPACKE_malloc( (m-1) * sizeof(lapack_complex_double) ); c_i = (lapack_complex_double *) LAPACKE_malloc( ldc*n * sizeof(lapack_complex_double) ); work_i = (lapack_complex_double *) LAPACKE_malloc( lwork * sizeof(lapack_complex_double) ); /* Allocate memory for the backup arrays */ c_save = (lapack_complex_double *) LAPACKE_malloc( ldc*n * sizeof(lapack_complex_double) ); /* Allocate memory for the row-major arrays */ ap_r = (lapack_complex_double *) LAPACKE_malloc( m*(m+1)/2 * sizeof(lapack_complex_double) ); c_r = (lapack_complex_double *) LAPACKE_malloc( m*(n+2) * sizeof(lapack_complex_double) ); /* 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 */ zupmtr_( &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_zupmtr_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_zupmtr( c, c_i, info, info_i, ldc, n ); if( failed == 0 ) { printf( "PASSED: column-major middle-level interface to zupmtr\n" ); } else { printf( "FAILED: column-major middle-level interface to zupmtr\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_zupmtr( LAPACK_COL_MAJOR, side_i, uplo_i, trans_i, m_i, n_i, ap_i, tau_i, c_i, ldc_i ); failed = compare_zupmtr( c, c_i, info, info_i, ldc, n ); if( failed == 0 ) { printf( "PASSED: column-major high-level interface to zupmtr\n" ); } else { printf( "FAILED: column-major high-level interface to zupmtr\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_zpp_trans( LAPACK_COL_MAJOR, uplo, m, ap_i, ap_r ); LAPACKE_zge_trans( LAPACK_COL_MAJOR, m, n, c_i, ldc, c_r, n+2 ); info_i = LAPACKE_zupmtr_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_zge_trans( LAPACK_ROW_MAJOR, m, n, c_r, n+2, c_i, ldc ); failed = compare_zupmtr( c, c_i, info, info_i, ldc, n ); if( failed == 0 ) { printf( "PASSED: row-major middle-level interface to zupmtr\n" ); } else { printf( "FAILED: row-major middle-level interface to zupmtr\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_zpp_trans( LAPACK_COL_MAJOR, uplo, m, ap_i, ap_r ); LAPACKE_zge_trans( LAPACK_COL_MAJOR, m, n, c_i, ldc, c_r, n+2 ); info_i = LAPACKE_zupmtr( LAPACK_ROW_MAJOR, side_i, uplo_i, trans_i, m_i, n_i, ap_r, tau_i, c_r, ldc_r ); LAPACKE_zge_trans( LAPACK_ROW_MAJOR, m, n, c_r, n+2, c_i, ldc ); failed = compare_zupmtr( c, c_i, info, info_i, ldc, n ); if( failed == 0 ) { printf( "PASSED: row-major high-level interface to zupmtr\n" ); } else { printf( "FAILED: row-major high-level interface to zupmtr\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; }
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_double *ap = NULL, *ap_i = NULL; lapack_complex_double *afp = NULL, *afp_i = NULL; lapack_complex_double *b = NULL, *b_i = NULL; lapack_complex_double *x = NULL, *x_i = NULL; double *ferr = NULL, *ferr_i = NULL; double *berr = NULL, *berr_i = NULL; lapack_complex_double *work = NULL, *work_i = NULL; double *rwork = NULL, *rwork_i = NULL; lapack_complex_double *x_save = NULL; double *ferr_save = NULL; double *berr_save = NULL; lapack_complex_double *ap_r = NULL; lapack_complex_double *afp_r = NULL; lapack_complex_double *b_r = NULL; lapack_complex_double *x_r = NULL; /* Iniitialize the scalar parameters */ init_scalars_zpprfs( &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_double *) LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_double) ); afp = (lapack_complex_double *) LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_double) ); b = (lapack_complex_double *) LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_double) ); x = (lapack_complex_double *) LAPACKE_malloc( ldx*nrhs * sizeof(lapack_complex_double) ); ferr = (double *)LAPACKE_malloc( nrhs * sizeof(double) ); berr = (double *)LAPACKE_malloc( nrhs * sizeof(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 */ ap_i = (lapack_complex_double *) LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_double) ); afp_i = (lapack_complex_double *) LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_double) ); b_i = (lapack_complex_double *) LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_double) ); x_i = (lapack_complex_double *) LAPACKE_malloc( ldx*nrhs * sizeof(lapack_complex_double) ); ferr_i = (double *)LAPACKE_malloc( nrhs * sizeof(double) ); berr_i = (double *)LAPACKE_malloc( nrhs * sizeof(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 backup arrays */ x_save = (lapack_complex_double *) LAPACKE_malloc( ldx*nrhs * sizeof(lapack_complex_double) ); ferr_save = (double *)LAPACKE_malloc( nrhs * sizeof(double) ); berr_save = (double *)LAPACKE_malloc( nrhs * sizeof(double) ); /* Allocate memory for the row-major arrays */ ap_r = (lapack_complex_double *) LAPACKE_malloc( n*(n+1)/2 * sizeof(lapack_complex_double) ); afp_r = (lapack_complex_double *) LAPACKE_malloc( n*(n+1)/2 * sizeof(lapack_complex_double) ); b_r = (lapack_complex_double *) LAPACKE_malloc( n*(nrhs+2) * sizeof(lapack_complex_double) ); x_r = (lapack_complex_double *) LAPACKE_malloc( n*(nrhs+2) * sizeof(lapack_complex_double) ); /* Initialize input arrays */ init_ap( (n*(n+1)/2), ap ); init_afp( (n*(n+1)/2), afp ); 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 */ zpprfs_( &uplo, &n, &nrhs, ap, afp, 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 < 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_zpprfs_work( LAPACK_COL_MAJOR, uplo_i, n_i, nrhs_i, ap_i, afp_i, b_i, ldb_i, x_i, ldx_i, ferr_i, berr_i, work_i, rwork_i ); failed = compare_zpprfs( 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 zpprfs\n" ); } else { printf( "FAILED: column-major middle-level interface to zpprfs\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 < 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_zpprfs( LAPACK_COL_MAJOR, uplo_i, n_i, nrhs_i, ap_i, afp_i, b_i, ldb_i, x_i, ldx_i, ferr_i, berr_i ); failed = compare_zpprfs( 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 zpprfs\n" ); } else { printf( "FAILED: column-major high-level interface to zpprfs\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 < 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_zpp_trans( LAPACK_COL_MAJOR, uplo, n, ap_i, ap_r ); LAPACKE_zpp_trans( LAPACK_COL_MAJOR, uplo, n, afp_i, afp_r ); LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 ); LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, nrhs, x_i, ldx, x_r, nrhs+2 ); info_i = LAPACKE_zpprfs_work( LAPACK_ROW_MAJOR, uplo_i, n_i, nrhs_i, ap_r, afp_r, b_r, ldb_r, x_r, ldx_r, ferr_i, berr_i, work_i, rwork_i ); LAPACKE_zge_trans( LAPACK_ROW_MAJOR, n, nrhs, x_r, nrhs+2, x_i, ldx ); failed = compare_zpprfs( 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 zpprfs\n" ); } else { printf( "FAILED: row-major middle-level interface to zpprfs\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 < 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_zpp_trans( LAPACK_COL_MAJOR, uplo, n, ap_i, ap_r ); LAPACKE_zpp_trans( LAPACK_COL_MAJOR, uplo, n, afp_i, afp_r ); LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 ); LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, nrhs, x_i, ldx, x_r, nrhs+2 ); info_i = LAPACKE_zpprfs( LAPACK_ROW_MAJOR, uplo_i, n_i, nrhs_i, ap_r, afp_r, b_r, ldb_r, x_r, ldx_r, ferr_i, berr_i ); LAPACKE_zge_trans( LAPACK_ROW_MAJOR, n, nrhs, x_r, nrhs+2, x_i, ldx ); failed = compare_zpprfs( 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 zpprfs\n" ); } else { printf( "FAILED: row-major high-level interface to zpprfs\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( 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; }