LAPACK  3.9.1
LAPACK: Linear Algebra PACKage

◆ LAPACKE_dtrevc_work()

lapack_int LAPACKE_dtrevc_work ( int  matrix_layout,
char  side,
char  howmny,
lapack_logical select,
lapack_int  n,
const double *  t,
lapack_int  ldt,
double *  vl,
lapack_int  ldvl,
double *  vr,
lapack_int  ldvr,
lapack_int  mm,
lapack_int m,
double *  work 
)

Definition at line 35 of file lapacke_dtrevc_work.c.

40 {
41  lapack_int info = 0;
42  if( matrix_layout == LAPACK_COL_MAJOR ) {
43  /* Call LAPACK function and adjust info */
44  LAPACK_dtrevc( &side, &howmny, select, &n, t, &ldt, vl, &ldvl, vr,
45  &ldvr, &mm, m, work, &info );
46  if( info < 0 ) {
47  info = info - 1;
48  }
49  } else if( matrix_layout == LAPACK_ROW_MAJOR ) {
50  lapack_int ldt_t = MAX(1,n);
51  lapack_int ldvl_t = MAX(1,n);
52  lapack_int ldvr_t = MAX(1,n);
53  double* t_t = NULL;
54  double* vl_t = NULL;
55  double* vr_t = NULL;
56  /* Check leading dimension(s) */
57  if( ldt < n ) {
58  info = -7;
59  LAPACKE_xerbla( "LAPACKE_dtrevc_work", info );
60  return info;
61  }
62  if( ldvl < mm ) {
63  info = -9;
64  LAPACKE_xerbla( "LAPACKE_dtrevc_work", info );
65  return info;
66  }
67  if( ldvr < mm ) {
68  info = -11;
69  LAPACKE_xerbla( "LAPACKE_dtrevc_work", info );
70  return info;
71  }
72  /* Allocate memory for temporary array(s) */
73  t_t = (double*)LAPACKE_malloc( sizeof(double) * ldt_t * MAX(1,n) );
74  if( t_t == NULL ) {
76  goto exit_level_0;
77  }
78  if( LAPACKE_lsame( side, 'b' ) || LAPACKE_lsame( side, 'l' ) ) {
79  vl_t = (double*)
80  LAPACKE_malloc( sizeof(double) * ldvl_t * MAX(1,mm) );
81  if( vl_t == NULL ) {
83  goto exit_level_1;
84  }
85  }
86  if( LAPACKE_lsame( side, 'b' ) || LAPACKE_lsame( side, 'r' ) ) {
87  vr_t = (double*)
88  LAPACKE_malloc( sizeof(double) * ldvr_t * MAX(1,mm) );
89  if( vr_t == NULL ) {
91  goto exit_level_2;
92  }
93  }
94  /* Transpose input matrices */
95  LAPACKE_dge_trans( matrix_layout, n, n, t, ldt, t_t, ldt_t );
96  if( ( LAPACKE_lsame( side, 'l' ) || LAPACKE_lsame( side, 'b' ) ) &&
97  LAPACKE_lsame( howmny, 'b' ) ) {
98  LAPACKE_dge_trans( matrix_layout, n, mm, vl, ldvl, vl_t, ldvl_t );
99  }
100  if( ( LAPACKE_lsame( side, 'r' ) || LAPACKE_lsame( side, 'b' ) ) &&
101  LAPACKE_lsame( howmny, 'b' ) ) {
102  LAPACKE_dge_trans( matrix_layout, n, mm, vr, ldvr, vr_t, ldvr_t );
103  }
104  /* Call LAPACK function and adjust info */
105  LAPACK_dtrevc( &side, &howmny, select, &n, t_t, &ldt_t, vl_t, &ldvl_t,
106  vr_t, &ldvr_t, &mm, m, work, &info );
107  if( info < 0 ) {
108  info = info - 1;
109  }
110  /* Transpose output matrices */
111  if( LAPACKE_lsame( side, 'b' ) || LAPACKE_lsame( side, 'l' ) ) {
112  LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, mm, vl_t, ldvl_t, vl,
113  ldvl );
114  }
115  if( LAPACKE_lsame( side, 'b' ) || LAPACKE_lsame( side, 'r' ) ) {
116  LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, mm, vr_t, ldvr_t, vr,
117  ldvr );
118  }
119  /* Release memory and exit */
120  if( LAPACKE_lsame( side, 'b' ) || LAPACKE_lsame( side, 'r' ) ) {
121  LAPACKE_free( vr_t );
122  }
123 exit_level_2:
124  if( LAPACKE_lsame( side, 'b' ) || LAPACKE_lsame( side, 'l' ) ) {
125  LAPACKE_free( vl_t );
126  }
127 exit_level_1:
128  LAPACKE_free( t_t );
129 exit_level_0:
130  if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
131  LAPACKE_xerbla( "LAPACKE_dtrevc_work", info );
132  }
133  } else {
134  info = -1;
135  LAPACKE_xerbla( "LAPACKE_dtrevc_work", info );
136  }
137  return info;
138 }
#define lapack_int
Definition: lapack.h:83
void LAPACK_dtrevc(char const *side, char const *howmny, lapack_logical *select, lapack_int const *n, double const *T, lapack_int const *ldt, double *VL, lapack_int const *ldvl, double *VR, lapack_int const *ldvr, lapack_int const *mm, lapack_int *m, double *work, 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: