LAPACK  3.9.1
LAPACK: Linear Algebra PACKage

◆ LAPACKE_dggevx_work()

lapack_int LAPACKE_dggevx_work ( int  matrix_layout,
char  balanc,
char  jobvl,
char  jobvr,
char  sense,
lapack_int  n,
double *  a,
lapack_int  lda,
double *  b,
lapack_int  ldb,
double *  alphar,
double *  alphai,
double *  beta,
double *  vl,
lapack_int  ldvl,
double *  vr,
lapack_int  ldvr,
lapack_int ilo,
lapack_int ihi,
double *  lscale,
double *  rscale,
double *  abnrm,
double *  bbnrm,
double *  rconde,
double *  rcondv,
double *  work,
lapack_int  lwork,
lapack_int iwork,
lapack_logical bwork 
)

Definition at line 35 of file lapacke_dggevx_work.c.

45 {
46  lapack_int info = 0;
47  if( matrix_layout == LAPACK_COL_MAJOR ) {
48  /* Call LAPACK function and adjust info */
49  LAPACK_dggevx( &balanc, &jobvl, &jobvr, &sense, &n, a, &lda, b, &ldb,
50  alphar, alphai, beta, vl, &ldvl, vr, &ldvr, ilo, ihi,
51  lscale, rscale, abnrm, bbnrm, rconde, rcondv, work,
52  &lwork, iwork, bwork, &info );
53  if( info < 0 ) {
54  info = info - 1;
55  }
56  } else if( matrix_layout == LAPACK_ROW_MAJOR ) {
57  lapack_int lda_t = MAX(1,n);
58  lapack_int ldb_t = MAX(1,n);
59  lapack_int ldvl_t = MAX(1,n);
60  lapack_int ldvr_t = MAX(1,n);
61  double* a_t = NULL;
62  double* b_t = NULL;
63  double* vl_t = NULL;
64  double* vr_t = NULL;
65  /* Check leading dimension(s) */
66  if( lda < n ) {
67  info = -8;
68  LAPACKE_xerbla( "LAPACKE_dggevx_work", info );
69  return info;
70  }
71  if( ldb < n ) {
72  info = -10;
73  LAPACKE_xerbla( "LAPACKE_dggevx_work", info );
74  return info;
75  }
76  if( ldvl < n ) {
77  info = -15;
78  LAPACKE_xerbla( "LAPACKE_dggevx_work", info );
79  return info;
80  }
81  if( ldvr < n ) {
82  info = -17;
83  LAPACKE_xerbla( "LAPACKE_dggevx_work", info );
84  return info;
85  }
86  /* Query optimal working array(s) size if requested */
87  if( lwork == -1 ) {
88  LAPACK_dggevx( &balanc, &jobvl, &jobvr, &sense, &n, a, &lda_t, b,
89  &ldb_t, alphar, alphai, beta, vl, &ldvl_t, vr,
90  &ldvr_t, ilo, ihi, lscale, rscale, abnrm, bbnrm,
91  rconde, rcondv, work, &lwork, iwork, bwork, &info );
92  return (info < 0) ? (info - 1) : info;
93  }
94  /* Allocate memory for temporary array(s) */
95  a_t = (double*)LAPACKE_malloc( sizeof(double) * lda_t * MAX(1,n) );
96  if( a_t == NULL ) {
98  goto exit_level_0;
99  }
100  b_t = (double*)LAPACKE_malloc( sizeof(double) * ldb_t * MAX(1,n) );
101  if( b_t == NULL ) {
103  goto exit_level_1;
104  }
105  if( LAPACKE_lsame( jobvl, 'v' ) ) {
106  vl_t = (double*)
107  LAPACKE_malloc( sizeof(double) * ldvl_t * MAX(1,n) );
108  if( vl_t == NULL ) {
110  goto exit_level_2;
111  }
112  }
113  if( LAPACKE_lsame( jobvr, 'v' ) ) {
114  vr_t = (double*)
115  LAPACKE_malloc( sizeof(double) * ldvr_t * MAX(1,n) );
116  if( vr_t == NULL ) {
118  goto exit_level_3;
119  }
120  }
121  /* Transpose input matrices */
122  LAPACKE_dge_trans( matrix_layout, n, n, a, lda, a_t, lda_t );
123  LAPACKE_dge_trans( matrix_layout, n, n, b, ldb, b_t, ldb_t );
124  /* Call LAPACK function and adjust info */
125  LAPACK_dggevx( &balanc, &jobvl, &jobvr, &sense, &n, a_t, &lda_t, b_t,
126  &ldb_t, alphar, alphai, beta, vl_t, &ldvl_t, vr_t,
127  &ldvr_t, ilo, ihi, lscale, rscale, abnrm, bbnrm, rconde,
128  rcondv, work, &lwork, iwork, bwork, &info );
129  if( info < 0 ) {
130  info = info - 1;
131  }
132  /* Transpose output matrices */
133  LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, a_t, lda_t, a, lda );
134  LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, b_t, ldb_t, b, ldb );
135  if( LAPACKE_lsame( jobvl, 'v' ) ) {
136  LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, vl_t, ldvl_t, vl, ldvl );
137  }
138  if( LAPACKE_lsame( jobvr, 'v' ) ) {
139  LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, vr_t, ldvr_t, vr, ldvr );
140  }
141  /* Release memory and exit */
142  if( LAPACKE_lsame( jobvr, 'v' ) ) {
143  LAPACKE_free( vr_t );
144  }
145 exit_level_3:
146  if( LAPACKE_lsame( jobvl, 'v' ) ) {
147  LAPACKE_free( vl_t );
148  }
149 exit_level_2:
150  LAPACKE_free( b_t );
151 exit_level_1:
152  LAPACKE_free( a_t );
153 exit_level_0:
154  if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
155  LAPACKE_xerbla( "LAPACKE_dggevx_work", info );
156  }
157  } else {
158  info = -1;
159  LAPACKE_xerbla( "LAPACKE_dggevx_work", info );
160  }
161  return info;
162 }
void LAPACK_dggevx(char const *balanc, char const *jobvl, char const *jobvr, char const *sense, lapack_int const *n, double *A, lapack_int const *lda, double *B, lapack_int const *ldb, double *alphar, double *alphai, double *beta, double *VL, lapack_int const *ldvl, double *VR, lapack_int const *ldvr, lapack_int *ilo, lapack_int *ihi, double *lscale, double *rscale, double *abnrm, double *bbnrm, double *rconde, double *rcondv, double *work, lapack_int const *lwork, lapack_int *iwork, lapack_logical *BWORK, lapack_int *info)
#define lapack_int
Definition: lapack.h:83
#define LAPACK_COL_MAJOR
Definition: lapacke.h:53
#define LAPACKE_free(p)
Definition: lapacke.h:46
#define LAPACK_ROW_MAJOR
Definition: lapacke.h:52
#define LAPACKE_malloc(size)
Definition: lapacke.h:43
#define LAPACK_TRANSPOSE_MEMORY_ERROR
Definition: lapacke.h:56
lapack_logical LAPACKE_lsame(char ca, char cb)
Definition: lapacke_lsame.c:35
void LAPACKE_xerbla(const char *name, lapack_int info)
#define MAX(x, y)
Definition: lapacke_utils.h:46
void LAPACKE_dge_trans(int matrix_layout, lapack_int m, lapack_int n, const double *in, lapack_int ldin, double *out, lapack_int ldout)
Here is the call graph for this function:
Here is the caller graph for this function: