LAPACK  3.9.1
LAPACK: Linear Algebra PACKage

◆ LAPACKE_dgeev_work()

lapack_int LAPACKE_dgeev_work ( int  matrix_layout,
char  jobvl,
char  jobvr,
lapack_int  n,
double *  a,
lapack_int  lda,
double *  wr,
double *  wi,
double *  vl,
lapack_int  ldvl,
double *  vr,
lapack_int  ldvr,
double *  work,
lapack_int  lwork 
)

Definition at line 35 of file lapacke_dgeev_work.c.

40 {
41  lapack_int info = 0;
42  if( matrix_layout == LAPACK_COL_MAJOR ) {
43  /* Call LAPACK function and adjust info */
44  LAPACK_dgeev( &jobvl, &jobvr, &n, a, &lda, wr, wi, vl, &ldvl, vr, &ldvr,
45  work, &lwork, &info );
46  if( info < 0 ) {
47  info = info - 1;
48  }
49  } else if( matrix_layout == LAPACK_ROW_MAJOR ) {
50  lapack_int lda_t = MAX(1,n);
51  lapack_int ldvl_t = MAX(1,n);
52  lapack_int ldvr_t = MAX(1,n);
53  double* a_t = NULL;
54  double* vl_t = NULL;
55  double* vr_t = NULL;
56  /* Check leading dimension(s) */
57  if( lda < n ) {
58  info = -6;
59  LAPACKE_xerbla( "LAPACKE_dgeev_work", info );
60  return info;
61  }
62  if( ldvl < n ) {
63  info = -10;
64  LAPACKE_xerbla( "LAPACKE_dgeev_work", info );
65  return info;
66  }
67  if( ldvr < n ) {
68  info = -12;
69  LAPACKE_xerbla( "LAPACKE_dgeev_work", info );
70  return info;
71  }
72  /* Query optimal working array(s) size if requested */
73  if( lwork == -1 ) {
74  LAPACK_dgeev( &jobvl, &jobvr, &n, a, &lda_t, wr, wi, vl, &ldvl_t,
75  vr, &ldvr_t, work, &lwork, &info );
76  return (info < 0) ? (info - 1) : info;
77  }
78  /* Allocate memory for temporary array(s) */
79  a_t = (double*)LAPACKE_malloc( sizeof(double) * lda_t * MAX(1,n) );
80  if( a_t == NULL ) {
82  goto exit_level_0;
83  }
84  if( LAPACKE_lsame( jobvl, 'v' ) ) {
85  vl_t = (double*)
86  LAPACKE_malloc( sizeof(double) * ldvl_t * MAX(1,n) );
87  if( vl_t == NULL ) {
89  goto exit_level_1;
90  }
91  }
92  if( LAPACKE_lsame( jobvr, 'v' ) ) {
93  vr_t = (double*)
94  LAPACKE_malloc( sizeof(double) * ldvr_t * MAX(1,n) );
95  if( vr_t == NULL ) {
97  goto exit_level_2;
98  }
99  }
100  /* Transpose input matrices */
101  LAPACKE_dge_trans( matrix_layout, n, n, a, lda, a_t, lda_t );
102  /* Call LAPACK function and adjust info */
103  LAPACK_dgeev( &jobvl, &jobvr, &n, a_t, &lda_t, wr, wi, vl_t, &ldvl_t,
104  vr_t, &ldvr_t, work, &lwork, &info );
105  if( info < 0 ) {
106  info = info - 1;
107  }
108  /* Transpose output matrices */
109  LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, a_t, lda_t, a, lda );
110  if( LAPACKE_lsame( jobvl, 'v' ) ) {
111  LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, vl_t, ldvl_t, vl, ldvl );
112  }
113  if( LAPACKE_lsame( jobvr, 'v' ) ) {
114  LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, vr_t, ldvr_t, vr, ldvr );
115  }
116  /* Release memory and exit */
117  if( LAPACKE_lsame( jobvr, 'v' ) ) {
118  LAPACKE_free( vr_t );
119  }
120 exit_level_2:
121  if( LAPACKE_lsame( jobvl, 'v' ) ) {
122  LAPACKE_free( vl_t );
123  }
124 exit_level_1:
125  LAPACKE_free( a_t );
126 exit_level_0:
127  if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
128  LAPACKE_xerbla( "LAPACKE_dgeev_work", info );
129  }
130  } else {
131  info = -1;
132  LAPACKE_xerbla( "LAPACKE_dgeev_work", info );
133  }
134  return info;
135 }
#define lapack_int
Definition: lapack.h:83
void LAPACK_dgeev(char const *jobvl, char const *jobvr, lapack_int const *n, double *A, lapack_int const *lda, double *WR, double *WI, double *VL, lapack_int const *ldvl, double *VR, lapack_int const *ldvr, double *work, lapack_int const *lwork, lapack_int *info)
#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: