lapack_int LAPACKE_chpgst_work( int matrix_order, lapack_int itype, char uplo, lapack_int n, lapack_complex_float* ap, const lapack_complex_float* bp ) { lapack_int info = 0; if( matrix_order == LAPACK_COL_MAJOR ) { /* Call LAPACK function and adjust info */ LAPACK_chpgst( &itype, &uplo, &n, ap, bp, &info ); if( info < 0 ) { info = info - 1; } } else if( matrix_order == LAPACK_ROW_MAJOR ) { lapack_complex_float* ap_t = NULL; lapack_complex_float* bp_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; } bp_t = (lapack_complex_float*) LAPACKE_malloc( sizeof(lapack_complex_float) * ( MAX(1,n) * MAX(2,n+1) ) / 2 ); if( bp_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_1; } /* Transpose input matrices */ LAPACKE_chp_trans( matrix_order, uplo, n, ap, ap_t ); LAPACKE_chp_trans( matrix_order, uplo, n, bp, bp_t ); /* Call LAPACK function and adjust info */ LAPACK_chpgst( &itype, &uplo, &n, ap_t, bp_t, &info ); if( info < 0 ) { info = info - 1; } /* Transpose output matrices */ LAPACKE_chp_trans( LAPACK_COL_MAJOR, uplo, n, ap_t, ap ); /* Release memory and exit */ LAPACKE_free( bp_t ); exit_level_1: LAPACKE_free( ap_t ); exit_level_0: if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_chpgst_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_chpgst_work", info ); } return info; }
lapack_int LAPACKE_chpcon_work( int matrix_order, char uplo, lapack_int n, const lapack_complex_float* ap, const lapack_int* ipiv, float anorm, float* rcond, lapack_complex_float* work ) { lapack_int info = 0; if( matrix_order == LAPACK_COL_MAJOR ) { /* Call LAPACK function and adjust info */ LAPACK_chpcon( &uplo, &n, ap, ipiv, &anorm, rcond, work, &info ); if( info < 0 ) { info = info - 1; } } else if( matrix_order == 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_chp_trans( matrix_order, uplo, n, ap, ap_t ); /* Call LAPACK function and adjust info */ LAPACK_chpcon( &uplo, &n, ap_t, ipiv, &anorm, rcond, work, &info ); if( info < 0 ) { info = info - 1; } /* Release memory and exit */ LAPACKE_free( ap_t ); exit_level_0: if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_chpcon_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_chpcon_work", info ); } return info; }
lapack_int LAPACKE_chpevd_work( int matrix_order, char jobz, char uplo, lapack_int n, lapack_complex_float* ap, float* w, lapack_complex_float* z, lapack_int ldz, lapack_complex_float* work, lapack_int lwork, float* rwork, lapack_int lrwork, lapack_int* iwork, lapack_int liwork ) { lapack_int info = 0; if( matrix_order == LAPACK_COL_MAJOR ) { /* Call LAPACK function and adjust info */ LAPACK_chpevd( &jobz, &uplo, &n, ap, w, z, &ldz, work, &lwork, rwork, &lrwork, iwork, &liwork, &info ); if( info < 0 ) { info = info - 1; } } else if( matrix_order == LAPACK_ROW_MAJOR ) { lapack_int ldz_t = MAX(1,n); lapack_complex_float* z_t = NULL; lapack_complex_float* ap_t = NULL; /* Check leading dimension(s) */ if( ldz < n ) { info = -8; LAPACKE_xerbla( "LAPACKE_chpevd_work", info ); return info; } /* Query optimal working array(s) size if requested */ if( liwork == -1 || lrwork == -1 || lwork == -1 ) { LAPACK_chpevd( &jobz, &uplo, &n, ap, w, z, &ldz_t, work, &lwork, rwork, &lrwork, iwork, &liwork, &info ); return (info < 0) ? (info - 1) : info; } /* Allocate memory for temporary array(s) */ if( LAPACKE_lsame( jobz, 'v' ) ) { z_t = (lapack_complex_float*) LAPACKE_malloc( sizeof(lapack_complex_float) * ldz_t * MAX(1,n) ); if( z_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_chp_trans( matrix_order, uplo, n, ap, ap_t ); /* Call LAPACK function and adjust info */ LAPACK_chpevd( &jobz, &uplo, &n, ap_t, w, z_t, &ldz_t, work, &lwork, rwork, &lrwork, iwork, &liwork, &info ); if( info < 0 ) { info = info - 1; } /* Transpose output matrices */ if( LAPACKE_lsame( jobz, 'v' ) ) { LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, z_t, ldz_t, z, ldz ); } LAPACKE_chp_trans( LAPACK_COL_MAJOR, uplo, n, ap_t, ap ); /* Release memory and exit */ LAPACKE_free( ap_t ); exit_level_1: if( LAPACKE_lsame( jobz, 'v' ) ) { LAPACKE_free( z_t ); } exit_level_0: if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_chpevd_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_chpevd_work", info ); } return info; }
lapack_int LAPACKE_chprfs_work( int matrix_order, char uplo, lapack_int n, lapack_int nrhs, const lapack_complex_float* ap, const lapack_complex_float* afp, const lapack_int* ipiv, const lapack_complex_float* b, lapack_int ldb, lapack_complex_float* x, lapack_int ldx, float* ferr, float* berr, lapack_complex_float* work, float* rwork ) { lapack_int info = 0; if( matrix_order == LAPACK_COL_MAJOR ) { /* Call LAPACK function and adjust info */ LAPACK_chprfs( &uplo, &n, &nrhs, ap, afp, ipiv, b, &ldb, x, &ldx, 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_float* b_t = NULL; lapack_complex_float* x_t = NULL; lapack_complex_float* ap_t = NULL; lapack_complex_float* afp_t = NULL; /* Check leading dimension(s) */ if( ldb < nrhs ) { info = -9; LAPACKE_xerbla( "LAPACKE_chprfs_work", info ); return info; } if( ldx < nrhs ) { info = -11; LAPACKE_xerbla( "LAPACKE_chprfs_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; } x_t = (lapack_complex_float*) LAPACKE_malloc( sizeof(lapack_complex_float) * ldx_t * MAX(1,nrhs) ); if( x_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_1; } 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_2; } afp_t = (lapack_complex_float*) LAPACKE_malloc( sizeof(lapack_complex_float) * ( 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_cge_trans( matrix_order, n, nrhs, b, ldb, b_t, ldb_t ); LAPACKE_cge_trans( matrix_order, n, nrhs, x, ldx, x_t, ldx_t ); LAPACKE_chp_trans( matrix_order, uplo, n, ap, ap_t ); LAPACKE_chp_trans( matrix_order, uplo, n, afp, afp_t ); /* Call LAPACK function and adjust info */ LAPACK_chprfs( &uplo, &n, &nrhs, ap_t, afp_t, ipiv, b_t, &ldb_t, x_t, &ldx_t, ferr, berr, work, rwork, &info ); if( info < 0 ) { info = info - 1; } /* Transpose output matrices */ LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, nrhs, x_t, ldx_t, x, ldx ); /* 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_chprfs_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_chprfs_work", info ); } return info; }
lapack_int LAPACKE_chpgvx_work( int matrix_layout, lapack_int itype, char jobz, char range, char uplo, lapack_int n, lapack_complex_float* ap, lapack_complex_float* bp, float vl, float vu, lapack_int il, lapack_int iu, float abstol, lapack_int* m, float* w, lapack_complex_float* z, lapack_int ldz, lapack_complex_float* work, float* rwork, lapack_int* iwork, lapack_int* ifail ) { lapack_int info = 0; if( matrix_layout == LAPACK_COL_MAJOR ) { /* Call LAPACK function and adjust info */ LAPACK_chpgvx( &itype, &jobz, &range, &uplo, &n, ap, bp, &vl, &vu, &il, &iu, &abstol, m, w, z, &ldz, work, rwork, iwork, ifail, &info ); if( info < 0 ) { info = info - 1; } } else if( matrix_layout == LAPACK_ROW_MAJOR ) { lapack_int ncols_z = ( LAPACKE_lsame( range, 'a' ) || LAPACKE_lsame( range, 'v' ) ) ? n : ( LAPACKE_lsame( range, 'i' ) ? (iu-il+1) : 1); lapack_int ldz_t = MAX(1,n); lapack_complex_float* z_t = NULL; lapack_complex_float* ap_t = NULL; lapack_complex_float* bp_t = NULL; /* Check leading dimension(s) */ if( ldz < ncols_z ) { info = -17; LAPACKE_xerbla( "LAPACKE_chpgvx_work", info ); return info; } /* Allocate memory for temporary array(s) */ if( LAPACKE_lsame( jobz, 'v' ) ) { z_t = (lapack_complex_float*) LAPACKE_malloc( sizeof(lapack_complex_float) * ldz_t * MAX(1,ncols_z) ); if( z_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; } bp_t = (lapack_complex_float*) LAPACKE_malloc( sizeof(lapack_complex_float) * ( MAX(1,n) * MAX(2,n+1) ) / 2 ); if( bp_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_2; } /* Transpose input matrices */ LAPACKE_chp_trans( matrix_layout, uplo, n, ap, ap_t ); LAPACKE_chp_trans( matrix_layout, uplo, n, bp, bp_t ); /* Call LAPACK function and adjust info */ LAPACK_chpgvx( &itype, &jobz, &range, &uplo, &n, ap_t, bp_t, &vl, &vu, &il, &iu, &abstol, m, w, z_t, &ldz_t, work, rwork, iwork, ifail, &info ); if( info < 0 ) { info = info - 1; } /* Transpose output matrices */ if( LAPACKE_lsame( jobz, 'v' ) ) { LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, ncols_z, z_t, ldz_t, z, ldz ); } LAPACKE_chp_trans( LAPACK_COL_MAJOR, uplo, n, ap_t, ap ); LAPACKE_chp_trans( LAPACK_COL_MAJOR, uplo, n, bp_t, bp ); /* Release memory and exit */ LAPACKE_free( bp_t ); exit_level_2: LAPACKE_free( ap_t ); exit_level_1: if( LAPACKE_lsame( jobz, 'v' ) ) { LAPACKE_free( z_t ); } exit_level_0: if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_chpgvx_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_chpgvx_work", info ); } return info; }