OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
lapacke_dhgeqz_work.c File Reference
#include "lapacke_utils.h"

Go to the source code of this file.

Functions

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)

Function Documentation

◆ LAPACKE_dhgeqz_work()

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 35 of file lapacke_dhgeqz_work.c.

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