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_ctgsen( int matrix_order, lapack_int ijob,
00038 lapack_logical wantq, lapack_logical wantz,
00039 const lapack_logical* select, lapack_int n,
00040 lapack_complex_float* a, lapack_int lda,
00041 lapack_complex_float* b, lapack_int ldb,
00042 lapack_complex_float* alpha,
00043 lapack_complex_float* beta, lapack_complex_float* q,
00044 lapack_int ldq, lapack_complex_float* z,
00045 lapack_int ldz, lapack_int* m, float* pl, float* pr,
00046 float* dif )
00047 {
00048 lapack_int info = 0;
00049 lapack_int liwork = -1;
00050 lapack_int lwork = -1;
00051 lapack_int* iwork = NULL;
00052 lapack_complex_float* work = NULL;
00053 lapack_int iwork_query;
00054 lapack_complex_float work_query;
00055 if( matrix_order != LAPACK_COL_MAJOR && matrix_order != LAPACK_ROW_MAJOR ) {
00056 LAPACKE_xerbla( "LAPACKE_ctgsen", -1 );
00057 return -1;
00058 }
00059 #ifndef LAPACK_DISABLE_NAN_CHECK
00060
00061 if( LAPACKE_cge_nancheck( matrix_order, n, n, a, lda ) ) {
00062 return -7;
00063 }
00064 if( LAPACKE_cge_nancheck( matrix_order, n, n, b, ldb ) ) {
00065 return -9;
00066 }
00067 if( wantq ) {
00068 if( LAPACKE_cge_nancheck( matrix_order, n, n, q, ldq ) ) {
00069 return -13;
00070 }
00071 }
00072 if( wantz ) {
00073 if( LAPACKE_cge_nancheck( matrix_order, n, n, z, ldz ) ) {
00074 return -15;
00075 }
00076 }
00077 #endif
00078
00079 info = LAPACKE_ctgsen_work( matrix_order, ijob, wantq, wantz, select, n, a,
00080 lda, b, ldb, alpha, beta, q, ldq, z, ldz, m, pl,
00081 pr, dif, &work_query, lwork, &iwork_query,
00082 liwork );
00083 if( info != 0 ) {
00084 goto exit_level_0;
00085 }
00086 liwork = (lapack_int)iwork_query;
00087 lwork = LAPACK_C2INT( work_query );
00088
00089 if( ijob != 0 ) {
00090 iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
00091 if( iwork == NULL ) {
00092 info = LAPACK_WORK_MEMORY_ERROR;
00093 goto exit_level_0;
00094 }
00095 }
00096 work = (lapack_complex_float*)
00097 LAPACKE_malloc( sizeof(lapack_complex_float) * lwork );
00098 if( work == NULL ) {
00099 info = LAPACK_WORK_MEMORY_ERROR;
00100 goto exit_level_1;
00101 }
00102
00103 info = LAPACKE_ctgsen_work( matrix_order, ijob, wantq, wantz, select, n, a,
00104 lda, b, ldb, alpha, beta, q, ldq, z, ldz, m, pl,
00105 pr, dif, work, lwork, iwork, liwork );
00106
00107 LAPACKE_free( work );
00108 exit_level_1:
00109 if( ijob != 0 ) {
00110 LAPACKE_free( iwork );
00111 }
00112 exit_level_0:
00113 if( info == LAPACK_WORK_MEMORY_ERROR ) {
00114 LAPACKE_xerbla( "LAPACKE_ctgsen", info );
00115 }
00116 return info;
00117 }