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_dtgsyl_work( int matrix_order, char trans, lapack_int ijob,
00038 lapack_int m, lapack_int n, const double* a,
00039 lapack_int lda, const double* b, lapack_int ldb,
00040 double* c, lapack_int ldc, const double* d,
00041 lapack_int ldd, const double* e, lapack_int lde,
00042 double* f, lapack_int ldf, double* scale,
00043 double* dif, double* work, lapack_int lwork,
00044 lapack_int* iwork )
00045 {
00046 lapack_int info = 0;
00047 if( matrix_order == LAPACK_COL_MAJOR ) {
00048
00049 LAPACK_dtgsyl( &trans, &ijob, &m, &n, a, &lda, b, &ldb, c, &ldc, d,
00050 &ldd, e, &lde, f, &ldf, scale, dif, work, &lwork, iwork,
00051 &info );
00052 if( info < 0 ) {
00053 info = info - 1;
00054 }
00055 } else if( matrix_order == LAPACK_ROW_MAJOR ) {
00056 lapack_int lda_t = MAX(1,m);
00057 lapack_int ldb_t = MAX(1,n);
00058 lapack_int ldc_t = MAX(1,m);
00059 lapack_int ldd_t = MAX(1,m);
00060 lapack_int lde_t = MAX(1,n);
00061 lapack_int ldf_t = MAX(1,m);
00062 double* a_t = NULL;
00063 double* b_t = NULL;
00064 double* c_t = NULL;
00065 double* d_t = NULL;
00066 double* e_t = NULL;
00067 double* f_t = NULL;
00068
00069 if( lda < m ) {
00070 info = -7;
00071 LAPACKE_xerbla( "LAPACKE_dtgsyl_work", info );
00072 return info;
00073 }
00074 if( ldb < n ) {
00075 info = -9;
00076 LAPACKE_xerbla( "LAPACKE_dtgsyl_work", info );
00077 return info;
00078 }
00079 if( ldc < n ) {
00080 info = -11;
00081 LAPACKE_xerbla( "LAPACKE_dtgsyl_work", info );
00082 return info;
00083 }
00084 if( ldd < m ) {
00085 info = -13;
00086 LAPACKE_xerbla( "LAPACKE_dtgsyl_work", info );
00087 return info;
00088 }
00089 if( lde < n ) {
00090 info = -15;
00091 LAPACKE_xerbla( "LAPACKE_dtgsyl_work", info );
00092 return info;
00093 }
00094 if( ldf < n ) {
00095 info = -17;
00096 LAPACKE_xerbla( "LAPACKE_dtgsyl_work", info );
00097 return info;
00098 }
00099
00100 if( lwork == -1 ) {
00101 LAPACK_dtgsyl( &trans, &ijob, &m, &n, a, &lda_t, b, &ldb_t, c,
00102 &ldc_t, d, &ldd_t, e, &lde_t, f, &ldf_t, scale, dif,
00103 work, &lwork, iwork, &info );
00104 return (info < 0) ? (info - 1) : info;
00105 }
00106
00107 a_t = (double*)LAPACKE_malloc( sizeof(double) * lda_t * MAX(1,m) );
00108 if( a_t == NULL ) {
00109 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00110 goto exit_level_0;
00111 }
00112 b_t = (double*)LAPACKE_malloc( sizeof(double) * ldb_t * MAX(1,n) );
00113 if( b_t == NULL ) {
00114 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00115 goto exit_level_1;
00116 }
00117 c_t = (double*)LAPACKE_malloc( sizeof(double) * ldc_t * MAX(1,n) );
00118 if( c_t == NULL ) {
00119 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00120 goto exit_level_2;
00121 }
00122 d_t = (double*)LAPACKE_malloc( sizeof(double) * ldd_t * MAX(1,m) );
00123 if( d_t == NULL ) {
00124 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00125 goto exit_level_3;
00126 }
00127 e_t = (double*)LAPACKE_malloc( sizeof(double) * lde_t * MAX(1,n) );
00128 if( e_t == NULL ) {
00129 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00130 goto exit_level_4;
00131 }
00132 f_t = (double*)LAPACKE_malloc( sizeof(double) * ldf_t * MAX(1,n) );
00133 if( f_t == NULL ) {
00134 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00135 goto exit_level_5;
00136 }
00137
00138 LAPACKE_dge_trans( matrix_order, m, m, a, lda, a_t, lda_t );
00139 LAPACKE_dge_trans( matrix_order, n, n, b, ldb, b_t, ldb_t );
00140 LAPACKE_dge_trans( matrix_order, m, n, c, ldc, c_t, ldc_t );
00141 LAPACKE_dge_trans( matrix_order, m, m, d, ldd, d_t, ldd_t );
00142 LAPACKE_dge_trans( matrix_order, n, n, e, lde, e_t, lde_t );
00143 LAPACKE_dge_trans( matrix_order, m, n, f, ldf, f_t, ldf_t );
00144
00145 LAPACK_dtgsyl( &trans, &ijob, &m, &n, a_t, &lda_t, b_t, &ldb_t, c_t,
00146 &ldc_t, d_t, &ldd_t, e_t, &lde_t, f_t, &ldf_t, scale,
00147 dif, work, &lwork, iwork, &info );
00148 if( info < 0 ) {
00149 info = info - 1;
00150 }
00151
00152 LAPACKE_dge_trans( LAPACK_COL_MAJOR, m, n, c_t, ldc_t, c, ldc );
00153 LAPACKE_dge_trans( LAPACK_COL_MAJOR, m, n, f_t, ldf_t, f, ldf );
00154
00155 LAPACKE_free( f_t );
00156 exit_level_5:
00157 LAPACKE_free( e_t );
00158 exit_level_4:
00159 LAPACKE_free( d_t );
00160 exit_level_3:
00161 LAPACKE_free( c_t );
00162 exit_level_2:
00163 LAPACKE_free( b_t );
00164 exit_level_1:
00165 LAPACKE_free( a_t );
00166 exit_level_0:
00167 if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
00168 LAPACKE_xerbla( "LAPACKE_dtgsyl_work", info );
00169 }
00170 } else {
00171 info = -1;
00172 LAPACKE_xerbla( "LAPACKE_dtgsyl_work", info );
00173 }
00174 return info;
00175 }