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_zhgeqz_work( int matrix_order, char job, char compq,
00038 char compz, lapack_int n, lapack_int ilo,
00039 lapack_int ihi, lapack_complex_double* h,
00040 lapack_int ldh, lapack_complex_double* t,
00041 lapack_int ldt, lapack_complex_double* alpha,
00042 lapack_complex_double* beta,
00043 lapack_complex_double* q, lapack_int ldq,
00044 lapack_complex_double* z, lapack_int ldz,
00045 lapack_complex_double* work, lapack_int lwork,
00046 double* rwork )
00047 {
00048 lapack_int info = 0;
00049 if( matrix_order == LAPACK_COL_MAJOR ) {
00050
00051 LAPACK_zhgeqz( &job, &compq, &compz, &n, &ilo, &ihi, h, &ldh, t, &ldt,
00052 alpha, beta, q, &ldq, z, &ldz, work, &lwork, rwork,
00053 &info );
00054 if( info < 0 ) {
00055 info = info - 1;
00056 }
00057 } else if( matrix_order == LAPACK_ROW_MAJOR ) {
00058 lapack_int ldh_t = MAX(1,n);
00059 lapack_int ldq_t = MAX(1,n);
00060 lapack_int ldt_t = MAX(1,n);
00061 lapack_int ldz_t = MAX(1,n);
00062 lapack_complex_double* h_t = NULL;
00063 lapack_complex_double* t_t = NULL;
00064 lapack_complex_double* q_t = NULL;
00065 lapack_complex_double* z_t = NULL;
00066
00067 if( ldh < n ) {
00068 info = -9;
00069 LAPACKE_xerbla( "LAPACKE_zhgeqz_work", info );
00070 return info;
00071 }
00072 if( ldq < n ) {
00073 info = -15;
00074 LAPACKE_xerbla( "LAPACKE_zhgeqz_work", info );
00075 return info;
00076 }
00077 if( ldt < n ) {
00078 info = -11;
00079 LAPACKE_xerbla( "LAPACKE_zhgeqz_work", info );
00080 return info;
00081 }
00082 if( ldz < n ) {
00083 info = -17;
00084 LAPACKE_xerbla( "LAPACKE_zhgeqz_work", info );
00085 return info;
00086 }
00087
00088 if( lwork == -1 ) {
00089 LAPACK_zhgeqz( &job, &compq, &compz, &n, &ilo, &ihi, h, &ldh_t, t,
00090 &ldt_t, alpha, beta, q, &ldq_t, z, &ldz_t, work,
00091 &lwork, rwork, &info );
00092 return (info < 0) ? (info - 1) : info;
00093 }
00094
00095 h_t = (lapack_complex_double*)
00096 LAPACKE_malloc( sizeof(lapack_complex_double) * ldh_t * MAX(1,n) );
00097 if( h_t == NULL ) {
00098 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00099 goto exit_level_0;
00100 }
00101 t_t = (lapack_complex_double*)
00102 LAPACKE_malloc( sizeof(lapack_complex_double) * ldt_t * MAX(1,n) );
00103 if( t_t == NULL ) {
00104 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00105 goto exit_level_1;
00106 }
00107 if( LAPACKE_lsame( compq, 'i' ) || LAPACKE_lsame( compq, 'v' ) ) {
00108 q_t = (lapack_complex_double*)
00109 LAPACKE_malloc( sizeof(lapack_complex_double) *
00110 ldq_t * MAX(1,n) );
00111 if( q_t == NULL ) {
00112 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00113 goto exit_level_2;
00114 }
00115 }
00116 if( LAPACKE_lsame( compz, 'i' ) || LAPACKE_lsame( compz, 'v' ) ) {
00117 z_t = (lapack_complex_double*)
00118 LAPACKE_malloc( sizeof(lapack_complex_double) *
00119 ldz_t * MAX(1,n) );
00120 if( z_t == NULL ) {
00121 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00122 goto exit_level_3;
00123 }
00124 }
00125
00126 LAPACKE_zge_trans( matrix_order, n, n, h, ldh, h_t, ldh_t );
00127 LAPACKE_zge_trans( matrix_order, n, n, t, ldt, t_t, ldt_t );
00128 if( LAPACKE_lsame( compq, 'v' ) ) {
00129 LAPACKE_zge_trans( matrix_order, n, n, q, ldq, q_t, ldq_t );
00130 }
00131 if( LAPACKE_lsame( compz, 'v' ) ) {
00132 LAPACKE_zge_trans( matrix_order, n, n, z, ldz, z_t, ldz_t );
00133 }
00134
00135 LAPACK_zhgeqz( &job, &compq, &compz, &n, &ilo, &ihi, h_t, &ldh_t, t_t,
00136 &ldt_t, alpha, beta, q_t, &ldq_t, z_t, &ldz_t, work,
00137 &lwork, rwork, &info );
00138 if( info < 0 ) {
00139 info = info - 1;
00140 }
00141
00142 LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, h_t, ldh_t, h, ldh );
00143 LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, t_t, ldt_t, t, ldt );
00144 if( LAPACKE_lsame( compq, 'i' ) || LAPACKE_lsame( compq, 'v' ) ) {
00145 LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, q_t, ldq_t, q, ldq );
00146 }
00147 if( LAPACKE_lsame( compz, 'i' ) || LAPACKE_lsame( compz, 'v' ) ) {
00148 LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, z_t, ldz_t, z, ldz );
00149 }
00150
00151 if( LAPACKE_lsame( compz, 'i' ) || LAPACKE_lsame( compz, 'v' ) ) {
00152 LAPACKE_free( z_t );
00153 }
00154 exit_level_3:
00155 if( LAPACKE_lsame( compq, 'i' ) || LAPACKE_lsame( compq, 'v' ) ) {
00156 LAPACKE_free( q_t );
00157 }
00158 exit_level_2:
00159 LAPACKE_free( t_t );
00160 exit_level_1:
00161 LAPACKE_free( h_t );
00162 exit_level_0:
00163 if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
00164 LAPACKE_xerbla( "LAPACKE_zhgeqz_work", info );
00165 }
00166 } else {
00167 info = -1;
00168 LAPACKE_xerbla( "LAPACKE_zhgeqz_work", info );
00169 }
00170 return info;
00171 }