LAPACK  3.10.1
LAPACK: Linear Algebra PACKage

◆ LAPACKE_dggesx_work()

lapack_int LAPACKE_dggesx_work ( int  matrix_layout,
char  jobvsl,
char  jobvsr,
char  sort,
LAPACK_D_SELECT3  selctg,
char  sense,
lapack_int  n,
double *  a,
lapack_int  lda,
double *  b,
lapack_int  ldb,
lapack_int sdim,
double *  alphar,
double *  alphai,
double *  beta,
double *  vsl,
lapack_int  ldvsl,
double *  vsr,
lapack_int  ldvsr,
double *  rconde,
double *  rcondv,
double *  work,
lapack_int  lwork,
lapack_int iwork,
lapack_int  liwork,
lapack_logical bwork 
)

Definition at line 35 of file lapacke_dggesx_work.c.

45 {
46  lapack_int info = 0;
47  if( matrix_layout == LAPACK_COL_MAJOR ) {
48  /* Call LAPACK function and adjust info */
49  LAPACK_dggesx( &jobvsl, &jobvsr, &sort, selctg, &sense, &n, a, &lda, b,
50  &ldb, sdim, alphar, alphai, beta, vsl, &ldvsl, vsr,
51  &ldvsr, rconde, rcondv, work, &lwork, iwork, &liwork,
52  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 ldvsl_t = MAX(1,n);
60  lapack_int ldvsr_t = MAX(1,n);
61  double* a_t = NULL;
62  double* b_t = NULL;
63  double* vsl_t = NULL;
64  double* vsr_t = NULL;
65  /* Check leading dimension(s) */
66  if( lda < n ) {
67  info = -9;
68  LAPACKE_xerbla( "LAPACKE_dggesx_work", info );
69  return info;
70  }
71  if( ldb < n ) {
72  info = -11;
73  LAPACKE_xerbla( "LAPACKE_dggesx_work", info );
74  return info;
75  }
76  if( ldvsl < n ) {
77  info = -17;
78  LAPACKE_xerbla( "LAPACKE_dggesx_work", info );
79  return info;
80  }
81  if( ldvsr < n ) {
82  info = -19;
83  LAPACKE_xerbla( "LAPACKE_dggesx_work", info );
84  return info;
85  }
86  /* Query optimal working array(s) size if requested */
87  if( liwork == -1 || lwork == -1 ) {
88  LAPACK_dggesx( &jobvsl, &jobvsr, &sort, selctg, &sense, &n, a,
89  &lda_t, b, &ldb_t, sdim, alphar, alphai, beta, vsl,
90  &ldvsl_t, vsr, &ldvsr_t, rconde, rcondv, work,
91  &lwork, iwork, &liwork, 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( jobvsl, 'v' ) ) {
106  vsl_t = (double*)
107  LAPACKE_malloc( sizeof(double) * ldvsl_t * MAX(1,n) );
108  if( vsl_t == NULL ) {
110  goto exit_level_2;
111  }
112  }
113  if( LAPACKE_lsame( jobvsr, 'v' ) ) {
114  vsr_t = (double*)
115  LAPACKE_malloc( sizeof(double) * ldvsr_t * MAX(1,n) );
116  if( vsr_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_dggesx( &jobvsl, &jobvsr, &sort, selctg, &sense, &n, a_t, &lda_t,
126  b_t, &ldb_t, sdim, alphar, alphai, beta, vsl_t, &ldvsl_t,
127  vsr_t, &ldvsr_t, rconde, rcondv, work, &lwork, iwork,
128  &liwork, 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( jobvsl, 'v' ) ) {
136  LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, vsl_t, ldvsl_t, vsl,
137  ldvsl );
138  }
139  if( LAPACKE_lsame( jobvsr, 'v' ) ) {
140  LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, vsr_t, ldvsr_t, vsr,
141  ldvsr );
142  }
143  /* Release memory and exit */
144  if( LAPACKE_lsame( jobvsr, 'v' ) ) {
145  LAPACKE_free( vsr_t );
146  }
147 exit_level_3:
148  if( LAPACKE_lsame( jobvsl, 'v' ) ) {
149  LAPACKE_free( vsl_t );
150  }
151 exit_level_2:
152  LAPACKE_free( b_t );
153 exit_level_1:
154  LAPACKE_free( a_t );
155 exit_level_0:
156  if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
157  LAPACKE_xerbla( "LAPACKE_dggesx_work", info );
158  }
159  } else {
160  info = -1;
161  LAPACKE_xerbla( "LAPACKE_dggesx_work", info );
162  }
163  return info;
164 }
#define lapack_int
Definition: lapack.h:83
#define LAPACK_dggesx(...)
Definition: lapack.h:4585
#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: