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_zhbgvx_work( int matrix_order, char jobz, char range,
00038 char uplo, lapack_int n, lapack_int ka,
00039 lapack_int kb, lapack_complex_double* ab,
00040 lapack_int ldab, lapack_complex_double* bb,
00041 lapack_int ldbb, lapack_complex_double* q,
00042 lapack_int ldq, double vl, double vu,
00043 lapack_int il, lapack_int iu, double abstol,
00044 lapack_int* m, double* w,
00045 lapack_complex_double* z, lapack_int ldz,
00046 lapack_complex_double* work, double* rwork,
00047 lapack_int* iwork, lapack_int* ifail )
00048 {
00049 lapack_int info = 0;
00050 if( matrix_order == LAPACK_COL_MAJOR ) {
00051
00052 LAPACK_zhbgvx( &jobz, &range, &uplo, &n, &ka, &kb, ab, &ldab, bb, &ldbb,
00053 q, &ldq, &vl, &vu, &il, &iu, &abstol, m, w, z, &ldz,
00054 work, rwork, iwork, ifail, &info );
00055 if( info < 0 ) {
00056 info = info - 1;
00057 }
00058 } else if( matrix_order == LAPACK_ROW_MAJOR ) {
00059 lapack_int ldab_t = MAX(1,ka+1);
00060 lapack_int ldbb_t = MAX(1,kb+1);
00061 lapack_int ldq_t = MAX(1,n);
00062 lapack_int ldz_t = MAX(1,n);
00063 lapack_complex_double* ab_t = NULL;
00064 lapack_complex_double* bb_t = NULL;
00065 lapack_complex_double* q_t = NULL;
00066 lapack_complex_double* z_t = NULL;
00067
00068 if( ldab < n ) {
00069 info = -9;
00070 LAPACKE_xerbla( "LAPACKE_zhbgvx_work", info );
00071 return info;
00072 }
00073 if( ldbb < n ) {
00074 info = -11;
00075 LAPACKE_xerbla( "LAPACKE_zhbgvx_work", info );
00076 return info;
00077 }
00078 if( ldq < n ) {
00079 info = -13;
00080 LAPACKE_xerbla( "LAPACKE_zhbgvx_work", info );
00081 return info;
00082 }
00083 if( ldz < n ) {
00084 info = -22;
00085 LAPACKE_xerbla( "LAPACKE_zhbgvx_work", info );
00086 return info;
00087 }
00088
00089 ab_t = (lapack_complex_double*)
00090 LAPACKE_malloc( sizeof(lapack_complex_double) * ldab_t * MAX(1,n) );
00091 if( ab_t == NULL ) {
00092 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00093 goto exit_level_0;
00094 }
00095 bb_t = (lapack_complex_double*)
00096 LAPACKE_malloc( sizeof(lapack_complex_double) * ldbb_t * MAX(1,n) );
00097 if( bb_t == NULL ) {
00098 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00099 goto exit_level_1;
00100 }
00101 if( LAPACKE_lsame( jobz, 'v' ) ) {
00102 q_t = (lapack_complex_double*)
00103 LAPACKE_malloc( sizeof(lapack_complex_double) *
00104 ldq_t * MAX(1,n) );
00105 if( q_t == NULL ) {
00106 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00107 goto exit_level_2;
00108 }
00109 }
00110 if( LAPACKE_lsame( jobz, 'v' ) ) {
00111 z_t = (lapack_complex_double*)
00112 LAPACKE_malloc( sizeof(lapack_complex_double) *
00113 ldz_t * MAX(1,n) );
00114 if( z_t == NULL ) {
00115 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00116 goto exit_level_3;
00117 }
00118 }
00119
00120 LAPACKE_zhb_trans( matrix_order, uplo, n, ka, ab, ldab, ab_t, ldab_t );
00121 LAPACKE_zhb_trans( matrix_order, uplo, n, kb, bb, ldbb, bb_t, ldbb_t );
00122
00123 LAPACK_zhbgvx( &jobz, &range, &uplo, &n, &ka, &kb, ab_t, &ldab_t, bb_t,
00124 &ldbb_t, q_t, &ldq_t, &vl, &vu, &il, &iu, &abstol, m, w,
00125 z_t, &ldz_t, work, rwork, iwork, ifail, &info );
00126 if( info < 0 ) {
00127 info = info - 1;
00128 }
00129
00130 LAPACKE_zhb_trans( LAPACK_COL_MAJOR, uplo, n, ka, ab_t, ldab_t, ab,
00131 ldab );
00132 LAPACKE_zhb_trans( LAPACK_COL_MAJOR, uplo, n, kb, bb_t, ldbb_t, bb,
00133 ldbb );
00134 if( LAPACKE_lsame( jobz, 'v' ) ) {
00135 LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, q_t, ldq_t, q, ldq );
00136 }
00137 if( LAPACKE_lsame( jobz, 'v' ) ) {
00138 LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, z_t, ldz_t, z, ldz );
00139 }
00140
00141 if( LAPACKE_lsame( jobz, 'v' ) ) {
00142 LAPACKE_free( z_t );
00143 }
00144 exit_level_3:
00145 if( LAPACKE_lsame( jobz, 'v' ) ) {
00146 LAPACKE_free( q_t );
00147 }
00148 exit_level_2:
00149 LAPACKE_free( bb_t );
00150 exit_level_1:
00151 LAPACKE_free( ab_t );
00152 exit_level_0:
00153 if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
00154 LAPACKE_xerbla( "LAPACKE_zhbgvx_work", info );
00155 }
00156 } else {
00157 info = -1;
00158 LAPACKE_xerbla( "LAPACKE_zhbgvx_work", info );
00159 }
00160 return info;
00161 }