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_chseqr_work( int matrix_order, char job, char compz,
00038 lapack_int n, lapack_int ilo, lapack_int ihi,
00039 lapack_complex_float* h, lapack_int ldh,
00040 lapack_complex_float* w,
00041 lapack_complex_float* z, lapack_int ldz,
00042 lapack_complex_float* work, lapack_int lwork )
00043 {
00044 lapack_int info = 0;
00045 if( matrix_order == LAPACK_COL_MAJOR ) {
00046
00047 LAPACK_chseqr( &job, &compz, &n, &ilo, &ihi, h, &ldh, w, z, &ldz, work,
00048 &lwork, &info );
00049 if( info < 0 ) {
00050 info = info - 1;
00051 }
00052 } else if( matrix_order == LAPACK_ROW_MAJOR ) {
00053 lapack_int ldh_t = MAX(1,n);
00054 lapack_int ldz_t = MAX(1,n);
00055 lapack_complex_float* h_t = NULL;
00056 lapack_complex_float* z_t = NULL;
00057
00058 if( ldh < n ) {
00059 info = -8;
00060 LAPACKE_xerbla( "LAPACKE_chseqr_work", info );
00061 return info;
00062 }
00063 if( ldz < n ) {
00064 info = -11;
00065 LAPACKE_xerbla( "LAPACKE_chseqr_work", info );
00066 return info;
00067 }
00068
00069 if( lwork == -1 ) {
00070 LAPACK_chseqr( &job, &compz, &n, &ilo, &ihi, h, &ldh_t, w, z,
00071 &ldz_t, work, &lwork, &info );
00072 return (info < 0) ? (info - 1) : info;
00073 }
00074
00075 h_t = (lapack_complex_float*)
00076 LAPACKE_malloc( sizeof(lapack_complex_float) * ldh_t * MAX(1,n) );
00077 if( h_t == NULL ) {
00078 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00079 goto exit_level_0;
00080 }
00081 if( LAPACKE_lsame( compz, 'i' ) || LAPACKE_lsame( compz, 'v' ) ) {
00082 z_t = (lapack_complex_float*)
00083 LAPACKE_malloc( sizeof(lapack_complex_float) *
00084 ldz_t * MAX(1,n) );
00085 if( z_t == NULL ) {
00086 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00087 goto exit_level_1;
00088 }
00089 }
00090
00091 LAPACKE_cge_trans( matrix_order, n, n, h, ldh, h_t, ldh_t );
00092 if( LAPACKE_lsame( compz, 'v' ) ) {
00093 LAPACKE_cge_trans( matrix_order, n, n, z, ldz, z_t, ldz_t );
00094 }
00095
00096 LAPACK_chseqr( &job, &compz, &n, &ilo, &ihi, h_t, &ldh_t, w, z_t,
00097 &ldz_t, work, &lwork, &info );
00098 if( info < 0 ) {
00099 info = info - 1;
00100 }
00101
00102 LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, h_t, ldh_t, h, ldh );
00103 if( LAPACKE_lsame( compz, 'i' ) || LAPACKE_lsame( compz, 'v' ) ) {
00104 LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, z_t, ldz_t, z, ldz );
00105 }
00106
00107 if( LAPACKE_lsame( compz, 'i' ) || LAPACKE_lsame( compz, 'v' ) ) {
00108 LAPACKE_free( z_t );
00109 }
00110 exit_level_1:
00111 LAPACKE_free( h_t );
00112 exit_level_0:
00113 if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
00114 LAPACKE_xerbla( "LAPACKE_chseqr_work", info );
00115 }
00116 } else {
00117 info = -1;
00118 LAPACKE_xerbla( "LAPACKE_chseqr_work", info );
00119 }
00120 return info;
00121 }