LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
lapack_int LAPACKE_dhgeqz_work ( int  matrix_layout,
char  job,
char  compq,
char  compz,
lapack_int  n,
lapack_int  ilo,
lapack_int  ihi,
double *  h,
lapack_int  ldh,
double *  t,
lapack_int  ldt,
double *  alphar,
double *  alphai,
double *  beta,
double *  q,
lapack_int  ldq,
double *  z,
lapack_int  ldz,
double *  work,
lapack_int  lwork 
)

Definition at line 36 of file lapacke_dhgeqz_work.c.

43 {
44  lapack_int info = 0;
45  if( matrix_layout == LAPACK_COL_MAJOR ) {
46  /* Call LAPACK function and adjust info */
47  LAPACK_dhgeqz( &job, &compq, &compz, &n, &ilo, &ihi, h, &ldh, t, &ldt,
48  alphar, alphai, beta, q, &ldq, z, &ldz, work, &lwork,
49  &info );
50  if( info < 0 ) {
51  info = info - 1;
52  }
53  } else if( matrix_layout == LAPACK_ROW_MAJOR ) {
54  lapack_int ldh_t = MAX(1,n);
55  lapack_int ldq_t = MAX(1,n);
56  lapack_int ldt_t = MAX(1,n);
57  lapack_int ldz_t = MAX(1,n);
58  double* h_t = NULL;
59  double* t_t = NULL;
60  double* q_t = NULL;
61  double* z_t = NULL;
62  /* Check leading dimension(s) */
63  if( ldh < n ) {
64  info = -9;
65  LAPACKE_xerbla( "LAPACKE_dhgeqz_work", info );
66  return info;
67  }
68  if( ldq < n ) {
69  info = -16;
70  LAPACKE_xerbla( "LAPACKE_dhgeqz_work", info );
71  return info;
72  }
73  if( ldt < n ) {
74  info = -11;
75  LAPACKE_xerbla( "LAPACKE_dhgeqz_work", info );
76  return info;
77  }
78  if( ldz < n ) {
79  info = -18;
80  LAPACKE_xerbla( "LAPACKE_dhgeqz_work", info );
81  return info;
82  }
83  /* Query optimal working array(s) size if requested */
84  if( lwork == -1 ) {
85  LAPACK_dhgeqz( &job, &compq, &compz, &n, &ilo, &ihi, h, &ldh_t, t,
86  &ldt_t, alphar, alphai, beta, q, &ldq_t, z, &ldz_t,
87  work, &lwork, &info );
88  return (info < 0) ? (info - 1) : info;
89  }
90  /* Allocate memory for temporary array(s) */
91  h_t = (double*)LAPACKE_malloc( sizeof(double) * ldh_t * MAX(1,n) );
92  if( h_t == NULL ) {
94  goto exit_level_0;
95  }
96  t_t = (double*)LAPACKE_malloc( sizeof(double) * ldt_t * MAX(1,n) );
97  if( t_t == NULL ) {
99  goto exit_level_1;
100  }
101  if( LAPACKE_lsame( compq, 'i' ) || LAPACKE_lsame( compq, 'v' ) ) {
102  q_t = (double*)LAPACKE_malloc( sizeof(double) * ldq_t * MAX(1,n) );
103  if( q_t == NULL ) {
105  goto exit_level_2;
106  }
107  }
108  if( LAPACKE_lsame( compz, 'i' ) || LAPACKE_lsame( compz, 'v' ) ) {
109  z_t = (double*)LAPACKE_malloc( sizeof(double) * ldz_t * MAX(1,n) );
110  if( z_t == NULL ) {
112  goto exit_level_3;
113  }
114  }
115  /* Transpose input matrices */
116  LAPACKE_dge_trans( matrix_layout, n, n, h, ldh, h_t, ldh_t );
117  LAPACKE_dge_trans( matrix_layout, n, n, t, ldt, t_t, ldt_t );
118  if( LAPACKE_lsame( compq, 'v' ) ) {
119  LAPACKE_dge_trans( matrix_layout, n, n, q, ldq, q_t, ldq_t );
120  }
121  if( LAPACKE_lsame( compz, 'v' ) ) {
122  LAPACKE_dge_trans( matrix_layout, n, n, z, ldz, z_t, ldz_t );
123  }
124  /* Call LAPACK function and adjust info */
125  LAPACK_dhgeqz( &job, &compq, &compz, &n, &ilo, &ihi, h_t, &ldh_t, t_t,
126  &ldt_t, alphar, alphai, beta, q_t, &ldq_t, z_t, &ldz_t,
127  work, &lwork, &info );
128  if( info < 0 ) {
129  info = info - 1;
130  }
131  /* Transpose output matrices */
132  LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, h_t, ldh_t, h, ldh );
133  LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, t_t, ldt_t, t, ldt );
134  if( LAPACKE_lsame( compq, 'i' ) || LAPACKE_lsame( compq, 'v' ) ) {
135  LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, q_t, ldq_t, q, ldq );
136  }
137  if( LAPACKE_lsame( compz, 'i' ) || LAPACKE_lsame( compz, 'v' ) ) {
138  LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, z_t, ldz_t, z, ldz );
139  }
140  /* Release memory and exit */
141  if( LAPACKE_lsame( compz, 'i' ) || LAPACKE_lsame( compz, 'v' ) ) {
142  LAPACKE_free( z_t );
143  }
144 exit_level_3:
145  if( LAPACKE_lsame( compq, 'i' ) || LAPACKE_lsame( compq, 'v' ) ) {
146  LAPACKE_free( q_t );
147  }
148 exit_level_2:
149  LAPACKE_free( t_t );
150 exit_level_1:
151  LAPACKE_free( h_t );
152 exit_level_0:
153  if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
154  LAPACKE_xerbla( "LAPACKE_dhgeqz_work", info );
155  }
156  } else {
157  info = -1;
158  LAPACKE_xerbla( "LAPACKE_dhgeqz_work", info );
159  }
160  return info;
161 }
void LAPACKE_dge_trans(int matrix_layout, lapack_int m, lapack_int n, const double *in, lapack_int ldin, double *out, lapack_int ldout)
#define LAPACK_ROW_MAJOR
Definition: lapacke.h:119
void LAPACK_dhgeqz(char *job, char *compq, char *compz, lapack_int *n, lapack_int *ilo, lapack_int *ihi, double *h, lapack_int *ldh, double *t, lapack_int *ldt, double *alphar, double *alphai, double *beta, double *q, lapack_int *ldq, double *z, lapack_int *ldz, double *work, lapack_int *lwork, lapack_int *info)
#define MAX(x, y)
Definition: lapacke_utils.h:47
#define LAPACKE_free(p)
Definition: lapacke.h:113
#define LAPACKE_malloc(size)
Definition: lapacke.h:110
lapack_logical LAPACKE_lsame(char ca, char cb)
Definition: lapacke_lsame.c:36
#define LAPACK_COL_MAJOR
Definition: lapacke.h:120
void LAPACKE_xerbla(const char *name, lapack_int info)
#define lapack_int
Definition: lapacke.h:47
#define LAPACK_TRANSPOSE_MEMORY_ERROR
Definition: lapacke.h:123

Here is the call graph for this function:

Here is the caller graph for this function: