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