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_zhsein_work( int matrix_order, char job, char eigsrc,
00038 char initv, const lapack_logical* select,
00039 lapack_int n, const lapack_complex_double* h,
00040 lapack_int ldh, lapack_complex_double* w,
00041 lapack_complex_double* vl, lapack_int ldvl,
00042 lapack_complex_double* vr, lapack_int ldvr,
00043 lapack_int mm, lapack_int* m,
00044 lapack_complex_double* work, double* rwork,
00045 lapack_int* ifaill, lapack_int* ifailr )
00046 {
00047 lapack_int info = 0;
00048 if( matrix_order == LAPACK_COL_MAJOR ) {
00049
00050 LAPACK_zhsein( &job, &eigsrc, &initv, select, &n, h, &ldh, w, vl, &ldvl,
00051 vr, &ldvr, &mm, m, work, rwork, ifaill, ifailr, &info );
00052 if( info < 0 ) {
00053 info = info - 1;
00054 }
00055 } else if( matrix_order == LAPACK_ROW_MAJOR ) {
00056 lapack_int ldh_t = MAX(1,n);
00057 lapack_int ldvl_t = MAX(1,n);
00058 lapack_int ldvr_t = MAX(1,n);
00059 lapack_complex_double* h_t = NULL;
00060 lapack_complex_double* vl_t = NULL;
00061 lapack_complex_double* vr_t = NULL;
00062
00063 if( ldh < n ) {
00064 info = -8;
00065 LAPACKE_xerbla( "LAPACKE_zhsein_work", info );
00066 return info;
00067 }
00068 if( ldvl < mm ) {
00069 info = -11;
00070 LAPACKE_xerbla( "LAPACKE_zhsein_work", info );
00071 return info;
00072 }
00073 if( ldvr < mm ) {
00074 info = -13;
00075 LAPACKE_xerbla( "LAPACKE_zhsein_work", info );
00076 return info;
00077 }
00078
00079 h_t = (lapack_complex_double*)
00080 LAPACKE_malloc( sizeof(lapack_complex_double) * ldh_t * MAX(1,n) );
00081 if( h_t == NULL ) {
00082 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00083 goto exit_level_0;
00084 }
00085 if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'l' ) ) {
00086 vl_t = (lapack_complex_double*)
00087 LAPACKE_malloc( sizeof(lapack_complex_double) *
00088 ldvl_t * MAX(1,mm) );
00089 if( vl_t == NULL ) {
00090 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00091 goto exit_level_1;
00092 }
00093 }
00094 if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'r' ) ) {
00095 vr_t = (lapack_complex_double*)
00096 LAPACKE_malloc( sizeof(lapack_complex_double) *
00097 ldvr_t * MAX(1,mm) );
00098 if( vr_t == NULL ) {
00099 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00100 goto exit_level_2;
00101 }
00102 }
00103
00104 LAPACKE_zge_trans( matrix_order, n, n, h, ldh, h_t, ldh_t );
00105 if( ( LAPACKE_lsame( job, 'l' ) || LAPACKE_lsame( job, 'b' ) ) &&
00106 LAPACKE_lsame( initv, 'v' ) ) {
00107 LAPACKE_zge_trans( matrix_order, n, mm, vl, ldvl, vl_t, ldvl_t );
00108 }
00109 if( ( LAPACKE_lsame( job, 'r' ) || LAPACKE_lsame( job, 'b' ) ) &&
00110 LAPACKE_lsame( initv, 'v' ) ) {
00111 LAPACKE_zge_trans( matrix_order, n, mm, vr, ldvr, vr_t, ldvr_t );
00112 }
00113
00114 LAPACK_zhsein( &job, &eigsrc, &initv, select, &n, h_t, &ldh_t, w, vl_t,
00115 &ldvl_t, vr_t, &ldvr_t, &mm, m, work, rwork, ifaill,
00116 ifailr, &info );
00117 if( info < 0 ) {
00118 info = info - 1;
00119 }
00120
00121 if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'l' ) ) {
00122 LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, mm, vl_t, ldvl_t, vl,
00123 ldvl );
00124 }
00125 if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'r' ) ) {
00126 LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, mm, vr_t, ldvr_t, vr,
00127 ldvr );
00128 }
00129
00130 if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'r' ) ) {
00131 LAPACKE_free( vr_t );
00132 }
00133 exit_level_2:
00134 if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'l' ) ) {
00135 LAPACKE_free( vl_t );
00136 }
00137 exit_level_1:
00138 LAPACKE_free( h_t );
00139 exit_level_0:
00140 if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
00141 LAPACKE_xerbla( "LAPACKE_zhsein_work", info );
00142 }
00143 } else {
00144 info = -1;
00145 LAPACKE_xerbla( "LAPACKE_zhsein_work", info );
00146 }
00147 return info;
00148 }