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_stgsen( int matrix_order, lapack_int ijob,
00038 lapack_logical wantq, lapack_logical wantz,
00039 const lapack_logical* select, lapack_int n, float* a,
00040 lapack_int lda, float* b, lapack_int ldb,
00041 float* alphar, float* alphai, float* beta, float* q,
00042 lapack_int ldq, float* z, lapack_int ldz,
00043 lapack_int* m, float* pl, float* pr, float* dif )
00044 {
00045 lapack_int info = 0;
00046 lapack_int liwork = -1;
00047 lapack_int lwork = -1;
00048 lapack_int* iwork = NULL;
00049 float* work = NULL;
00050 lapack_int iwork_query;
00051 float work_query;
00052 if( matrix_order != LAPACK_COL_MAJOR && matrix_order != LAPACK_ROW_MAJOR ) {
00053 LAPACKE_xerbla( "LAPACKE_stgsen", -1 );
00054 return -1;
00055 }
00056 #ifndef LAPACK_DISABLE_NAN_CHECK
00057
00058 if( LAPACKE_sge_nancheck( matrix_order, n, n, a, lda ) ) {
00059 return -7;
00060 }
00061 if( LAPACKE_sge_nancheck( matrix_order, n, n, b, ldb ) ) {
00062 return -9;
00063 }
00064 if( wantq ) {
00065 if( LAPACKE_sge_nancheck( matrix_order, n, n, q, ldq ) ) {
00066 return -14;
00067 }
00068 }
00069 if( wantz ) {
00070 if( LAPACKE_sge_nancheck( matrix_order, n, n, z, ldz ) ) {
00071 return -16;
00072 }
00073 }
00074 #endif
00075
00076 info = LAPACKE_stgsen_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 = (float*)LAPACKE_malloc( sizeof(float) * lwork );
00094 if( work == NULL ) {
00095 info = LAPACK_WORK_MEMORY_ERROR;
00096 goto exit_level_1;
00097 }
00098
00099 info = LAPACKE_stgsen_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_stgsen", info );
00112 }
00113 return info;
00114 }