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_ctgsna( int matrix_order, char job, char howmny,
00038 const lapack_logical* select, lapack_int n,
00039 const lapack_complex_float* a, lapack_int lda,
00040 const lapack_complex_float* b, lapack_int ldb,
00041 const lapack_complex_float* vl, lapack_int ldvl,
00042 const lapack_complex_float* vr, lapack_int ldvr,
00043 float* s, float* dif, lapack_int mm, lapack_int* m )
00044 {
00045 lapack_int info = 0;
00046 lapack_int lwork = -1;
00047 lapack_int* iwork = NULL;
00048 lapack_complex_float* work = NULL;
00049 lapack_complex_float work_query;
00050 if( matrix_order != LAPACK_COL_MAJOR && matrix_order != LAPACK_ROW_MAJOR ) {
00051 LAPACKE_xerbla( "LAPACKE_ctgsna", -1 );
00052 return -1;
00053 }
00054 #ifndef LAPACK_DISABLE_NAN_CHECK
00055
00056 if( LAPACKE_cge_nancheck( matrix_order, n, n, a, lda ) ) {
00057 return -6;
00058 }
00059 if( LAPACKE_cge_nancheck( matrix_order, n, n, b, ldb ) ) {
00060 return -8;
00061 }
00062 if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'e' ) ) {
00063 if( LAPACKE_cge_nancheck( matrix_order, n, mm, vl, ldvl ) ) {
00064 return -10;
00065 }
00066 }
00067 if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'e' ) ) {
00068 if( LAPACKE_cge_nancheck( matrix_order, n, mm, vr, ldvr ) ) {
00069 return -12;
00070 }
00071 }
00072 #endif
00073
00074 if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'v' ) ) {
00075 iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * MAX(1,n+2) );
00076 if( iwork == NULL ) {
00077 info = LAPACK_WORK_MEMORY_ERROR;
00078 goto exit_level_0;
00079 }
00080 }
00081
00082 info = LAPACKE_ctgsna_work( matrix_order, job, howmny, select, n, a, lda, b,
00083 ldb, vl, ldvl, vr, ldvr, s, dif, mm, m,
00084 &work_query, lwork, iwork );
00085 if( info != 0 ) {
00086 goto exit_level_1;
00087 }
00088 lwork = LAPACK_C2INT( work_query );
00089
00090 if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'v' ) ) {
00091 work = (lapack_complex_float*)
00092 LAPACKE_malloc( sizeof(lapack_complex_float) * lwork );
00093 if( work == NULL ) {
00094 info = LAPACK_WORK_MEMORY_ERROR;
00095 goto exit_level_1;
00096 }
00097 }
00098
00099 info = LAPACKE_ctgsna_work( matrix_order, job, howmny, select, n, a, lda, b,
00100 ldb, vl, ldvl, vr, ldvr, s, dif, mm, m, work,
00101 lwork, iwork );
00102
00103 if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'v' ) ) {
00104 LAPACKE_free( work );
00105 }
00106 exit_level_1:
00107 if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'v' ) ) {
00108 LAPACKE_free( iwork );
00109 }
00110 exit_level_0:
00111 if( info == LAPACK_WORK_MEMORY_ERROR ) {
00112 LAPACKE_xerbla( "LAPACKE_ctgsna", info );
00113 }
00114 return info;
00115 }