00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include "lapacke.h"
00035 #include "lapacke_utils.h"
00036
00037 lapack_int LAPACKE_sporfs_work( int matrix_order, char uplo, lapack_int n,
00038 lapack_int nrhs, const float* a, lapack_int lda,
00039 const float* af, lapack_int ldaf,
00040 const float* b, lapack_int ldb, float* x,
00041 lapack_int ldx, float* ferr, float* berr,
00042 float* work, lapack_int* iwork )
00043 {
00044 lapack_int info = 0;
00045 if( matrix_order == LAPACK_COL_MAJOR ) {
00046
00047 LAPACK_sporfs( &uplo, &n, &nrhs, a, &lda, af, &ldaf, b, &ldb, x, &ldx,
00048 ferr, berr, work, iwork, &info );
00049 if( info < 0 ) {
00050 info = info - 1;
00051 }
00052 } else if( matrix_order == LAPACK_ROW_MAJOR ) {
00053 lapack_int lda_t = MAX(1,n);
00054 lapack_int ldaf_t = MAX(1,n);
00055 lapack_int ldb_t = MAX(1,n);
00056 lapack_int ldx_t = MAX(1,n);
00057 float* a_t = NULL;
00058 float* af_t = NULL;
00059 float* b_t = NULL;
00060 float* x_t = NULL;
00061
00062 if( lda < n ) {
00063 info = -6;
00064 LAPACKE_xerbla( "LAPACKE_sporfs_work", info );
00065 return info;
00066 }
00067 if( ldaf < n ) {
00068 info = -8;
00069 LAPACKE_xerbla( "LAPACKE_sporfs_work", info );
00070 return info;
00071 }
00072 if( ldb < nrhs ) {
00073 info = -10;
00074 LAPACKE_xerbla( "LAPACKE_sporfs_work", info );
00075 return info;
00076 }
00077 if( ldx < nrhs ) {
00078 info = -12;
00079 LAPACKE_xerbla( "LAPACKE_sporfs_work", info );
00080 return info;
00081 }
00082
00083 a_t = (float*)LAPACKE_malloc( sizeof(float) * lda_t * MAX(1,n) );
00084 if( a_t == NULL ) {
00085 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00086 goto exit_level_0;
00087 }
00088 af_t = (float*)LAPACKE_malloc( sizeof(float) * ldaf_t * MAX(1,n) );
00089 if( af_t == NULL ) {
00090 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00091 goto exit_level_1;
00092 }
00093 b_t = (float*)LAPACKE_malloc( sizeof(float) * ldb_t * MAX(1,nrhs) );
00094 if( b_t == NULL ) {
00095 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00096 goto exit_level_2;
00097 }
00098 x_t = (float*)LAPACKE_malloc( sizeof(float) * ldx_t * MAX(1,nrhs) );
00099 if( x_t == NULL ) {
00100 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00101 goto exit_level_3;
00102 }
00103
00104 LAPACKE_spo_trans( matrix_order, uplo, n, a, lda, a_t, lda_t );
00105 LAPACKE_spo_trans( matrix_order, uplo, n, af, ldaf, af_t, ldaf_t );
00106 LAPACKE_sge_trans( matrix_order, n, nrhs, b, ldb, b_t, ldb_t );
00107 LAPACKE_sge_trans( matrix_order, n, nrhs, x, ldx, x_t, ldx_t );
00108
00109 LAPACK_sporfs( &uplo, &n, &nrhs, a_t, &lda_t, af_t, &ldaf_t, b_t,
00110 &ldb_t, x_t, &ldx_t, ferr, berr, work, iwork, &info );
00111 if( info < 0 ) {
00112 info = info - 1;
00113 }
00114
00115 LAPACKE_sge_trans( LAPACK_COL_MAJOR, n, nrhs, x_t, ldx_t, x, ldx );
00116
00117 LAPACKE_free( x_t );
00118 exit_level_3:
00119 LAPACKE_free( b_t );
00120 exit_level_2:
00121 LAPACKE_free( af_t );
00122 exit_level_1:
00123 LAPACKE_free( a_t );
00124 exit_level_0:
00125 if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
00126 LAPACKE_xerbla( "LAPACKE_sporfs_work", info );
00127 }
00128 } else {
00129 info = -1;
00130 LAPACKE_xerbla( "LAPACKE_sporfs_work", info );
00131 }
00132 return info;
00133 }