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_dgghrd_work( int matrix_order, char compq, char compz,
00038 lapack_int n, lapack_int ilo, lapack_int ihi,
00039 double* a, lapack_int lda, double* b,
00040 lapack_int ldb, double* q, lapack_int ldq,
00041 double* z, lapack_int ldz )
00042 {
00043 lapack_int info = 0;
00044 if( matrix_order == LAPACK_COL_MAJOR ) {
00045
00046 LAPACK_dgghrd( &compq, &compz, &n, &ilo, &ihi, a, &lda, b, &ldb, q,
00047 &ldq, z, &ldz, &info );
00048 if( info < 0 ) {
00049 info = info - 1;
00050 }
00051 } else if( matrix_order == LAPACK_ROW_MAJOR ) {
00052 lapack_int lda_t = MAX(1,n);
00053 lapack_int ldb_t = MAX(1,n);
00054 lapack_int ldq_t = MAX(1,n);
00055 lapack_int ldz_t = MAX(1,n);
00056 double* a_t = NULL;
00057 double* b_t = NULL;
00058 double* q_t = NULL;
00059 double* z_t = NULL;
00060
00061 if( lda < n ) {
00062 info = -8;
00063 LAPACKE_xerbla( "LAPACKE_dgghrd_work", info );
00064 return info;
00065 }
00066 if( ldb < n ) {
00067 info = -10;
00068 LAPACKE_xerbla( "LAPACKE_dgghrd_work", info );
00069 return info;
00070 }
00071 if( ldq < n ) {
00072 info = -12;
00073 LAPACKE_xerbla( "LAPACKE_dgghrd_work", info );
00074 return info;
00075 }
00076 if( ldz < n ) {
00077 info = -14;
00078 LAPACKE_xerbla( "LAPACKE_dgghrd_work", info );
00079 return info;
00080 }
00081
00082 a_t = (double*)LAPACKE_malloc( sizeof(double) * lda_t * MAX(1,n) );
00083 if( a_t == NULL ) {
00084 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00085 goto exit_level_0;
00086 }
00087 b_t = (double*)LAPACKE_malloc( sizeof(double) * ldb_t * MAX(1,n) );
00088 if( b_t == NULL ) {
00089 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00090 goto exit_level_1;
00091 }
00092 if( LAPACKE_lsame( compq, 'i' ) || LAPACKE_lsame( compq, 'v' ) ) {
00093 q_t = (double*)LAPACKE_malloc( sizeof(double) * ldq_t * MAX(1,n) );
00094 if( q_t == NULL ) {
00095 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00096 goto exit_level_2;
00097 }
00098 }
00099 if( LAPACKE_lsame( compz, 'i' ) || LAPACKE_lsame( compz, 'v' ) ) {
00100 z_t = (double*)LAPACKE_malloc( sizeof(double) * ldz_t * MAX(1,n) );
00101 if( z_t == NULL ) {
00102 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00103 goto exit_level_3;
00104 }
00105 }
00106
00107 LAPACKE_dge_trans( matrix_order, n, n, a, lda, a_t, lda_t );
00108 LAPACKE_dge_trans( matrix_order, n, n, b, ldb, b_t, ldb_t );
00109 if( LAPACKE_lsame( compq, 'v' ) ) {
00110 LAPACKE_dge_trans( matrix_order, n, n, q, ldq, q_t, ldq_t );
00111 }
00112 if( LAPACKE_lsame( compz, 'v' ) ) {
00113 LAPACKE_dge_trans( matrix_order, n, n, z, ldz, z_t, ldz_t );
00114 }
00115
00116 LAPACK_dgghrd( &compq, &compz, &n, &ilo, &ihi, a_t, &lda_t, b_t, &ldb_t,
00117 q_t, &ldq_t, z_t, &ldz_t, &info );
00118 if( info < 0 ) {
00119 info = info - 1;
00120 }
00121
00122 LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, a_t, lda_t, a, lda );
00123 LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, b_t, ldb_t, b, ldb );
00124 if( LAPACKE_lsame( compq, 'i' ) || LAPACKE_lsame( compq, 'v' ) ) {
00125 LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, q_t, ldq_t, q, ldq );
00126 }
00127 if( LAPACKE_lsame( compz, 'i' ) || LAPACKE_lsame( compz, 'v' ) ) {
00128 LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, z_t, ldz_t, z, ldz );
00129 }
00130
00131 if( LAPACKE_lsame( compz, 'i' ) || LAPACKE_lsame( compz, 'v' ) ) {
00132 LAPACKE_free( z_t );
00133 }
00134 exit_level_3:
00135 if( LAPACKE_lsame( compq, 'i' ) || LAPACKE_lsame( compq, 'v' ) ) {
00136 LAPACKE_free( q_t );
00137 }
00138 exit_level_2:
00139 LAPACKE_free( b_t );
00140 exit_level_1:
00141 LAPACKE_free( a_t );
00142 exit_level_0:
00143 if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
00144 LAPACKE_xerbla( "LAPACKE_dgghrd_work", info );
00145 }
00146 } else {
00147 info = -1;
00148 LAPACKE_xerbla( "LAPACKE_dgghrd_work", info );
00149 }
00150 return info;
00151 }