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