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_chbgst_work( int matrix_order, char vect, char uplo,
00038 lapack_int n, lapack_int ka, lapack_int kb,
00039 lapack_complex_float* ab, lapack_int ldab,
00040 const lapack_complex_float* bb, lapack_int ldbb,
00041 lapack_complex_float* x, lapack_int ldx,
00042 lapack_complex_float* work, float* rwork )
00043 {
00044 lapack_int info = 0;
00045 if( matrix_order == LAPACK_COL_MAJOR ) {
00046
00047 LAPACK_chbgst( &vect, &uplo, &n, &ka, &kb, ab, &ldab, bb, &ldbb, x,
00048 &ldx, work, rwork, &info );
00049 if( info < 0 ) {
00050 info = info - 1;
00051 }
00052 } else if( matrix_order == LAPACK_ROW_MAJOR ) {
00053 lapack_int ldab_t = MAX(1,ka+1);
00054 lapack_int ldbb_t = MAX(1,kb+1);
00055 lapack_int ldx_t = MAX(1,n);
00056 lapack_complex_float* ab_t = NULL;
00057 lapack_complex_float* bb_t = NULL;
00058 lapack_complex_float* x_t = NULL;
00059
00060 if( ldab < n ) {
00061 info = -8;
00062 LAPACKE_xerbla( "LAPACKE_chbgst_work", info );
00063 return info;
00064 }
00065 if( ldbb < n ) {
00066 info = -10;
00067 LAPACKE_xerbla( "LAPACKE_chbgst_work", info );
00068 return info;
00069 }
00070 if( ldx < n ) {
00071 info = -12;
00072 LAPACKE_xerbla( "LAPACKE_chbgst_work", info );
00073 return info;
00074 }
00075
00076 ab_t = (lapack_complex_float*)
00077 LAPACKE_malloc( sizeof(lapack_complex_float) * ldab_t * MAX(1,n) );
00078 if( ab_t == NULL ) {
00079 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00080 goto exit_level_0;
00081 }
00082 bb_t = (lapack_complex_float*)
00083 LAPACKE_malloc( sizeof(lapack_complex_float) * ldbb_t * MAX(1,n) );
00084 if( bb_t == NULL ) {
00085 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00086 goto exit_level_1;
00087 }
00088 if( LAPACKE_lsame( vect, 'v' ) ) {
00089 x_t = (lapack_complex_float*)
00090 LAPACKE_malloc( sizeof(lapack_complex_float) *
00091 ldx_t * MAX(1,n) );
00092 if( x_t == NULL ) {
00093 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00094 goto exit_level_2;
00095 }
00096 }
00097
00098 LAPACKE_chb_trans( matrix_order, uplo, n, ka, ab, ldab, ab_t, ldab_t );
00099 LAPACKE_chb_trans( matrix_order, uplo, n, kb, bb, ldbb, bb_t, ldbb_t );
00100
00101 LAPACK_chbgst( &vect, &uplo, &n, &ka, &kb, ab_t, &ldab_t, bb_t, &ldbb_t,
00102 x_t, &ldx_t, work, rwork, &info );
00103 if( info < 0 ) {
00104 info = info - 1;
00105 }
00106
00107 LAPACKE_chb_trans( LAPACK_COL_MAJOR, uplo, n, ka, ab_t, ldab_t, ab,
00108 ldab );
00109 if( LAPACKE_lsame( vect, 'v' ) ) {
00110 LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, x_t, ldx_t, x, ldx );
00111 }
00112
00113 if( LAPACKE_lsame( vect, 'v' ) ) {
00114 LAPACKE_free( x_t );
00115 }
00116 exit_level_2:
00117 LAPACKE_free( bb_t );
00118 exit_level_1:
00119 LAPACKE_free( ab_t );
00120 exit_level_0:
00121 if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
00122 LAPACKE_xerbla( "LAPACKE_chbgst_work", info );
00123 }
00124 } else {
00125 info = -1;
00126 LAPACKE_xerbla( "LAPACKE_chbgst_work", info );
00127 }
00128 return info;
00129 }