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

Go to the source code of this file.

Functions

lapack_int LAPACKE_dgges_work (int matrix_layout, char jobvsl, char jobvsr, char sort, LAPACK_D_SELECT3 selctg, 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 *work, lapack_int lwork, lapack_logical *bwork)

Function Documentation

◆ LAPACKE_dgges_work()

lapack_int LAPACKE_dgges_work ( int matrix_layout,
char jobvsl,
char jobvsr,
char sort,
LAPACK_D_SELECT3 selctg,
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 * work,
lapack_int lwork,
lapack_logical * bwork )

Definition at line 35 of file lapacke_dgges_work.c.

43{
44 lapack_int info = 0;
45 if( matrix_layout == LAPACK_COL_MAJOR ) {
46 /* Call LAPACK function and adjust info */
47 LAPACK_dgges( &jobvsl, &jobvsr, &sort, selctg, &n, a, &lda, b, &ldb,
48 sdim, alphar, alphai, beta, vsl, &ldvsl, vsr, &ldvsr,
49 work, &lwork, bwork, &info );
50 if( info < 0 ) {
51 info = info - 1;
52 }
53 } else if( matrix_layout == LAPACK_ROW_MAJOR ) {
54 lapack_int lda_t = MAX(1,n);
55 lapack_int ldb_t = MAX(1,n);
56 lapack_int ldvsl_t = MAX(1,n);
57 lapack_int ldvsr_t = MAX(1,n);
58 double* a_t = NULL;
59 double* b_t = NULL;
60 double* vsl_t = NULL;
61 double* vsr_t = NULL;
62 /* Check leading dimension(s) */
63 if( lda < n ) {
64 info = -8;
65 LAPACKE_xerbla( "LAPACKE_dgges_work", info );
66 return info;
67 }
68 if( ldb < n ) {
69 info = -10;
70 LAPACKE_xerbla( "LAPACKE_dgges_work", info );
71 return info;
72 }
73 if( ldvsl < n ) {
74 info = -16;
75 LAPACKE_xerbla( "LAPACKE_dgges_work", info );
76 return info;
77 }
78 if( ldvsr < n ) {
79 info = -18;
80 LAPACKE_xerbla( "LAPACKE_dgges_work", info );
81 return info;
82 }
83 /* Query optimal working array(s) size if requested */
84 if( lwork == -1 ) {
85 LAPACK_dgges( &jobvsl, &jobvsr, &sort, selctg, &n, a, &lda_t, b,
86 &ldb_t, sdim, alphar, alphai, beta, vsl, &ldvsl_t,
87 vsr, &ldvsr_t, work, &lwork, bwork, &info );
88 return (info < 0) ? (info - 1) : info;
89 }
90 /* Allocate memory for temporary array(s) */
91 a_t = (double*)LAPACKE_malloc( sizeof(double) * lda_t * MAX(1,n) );
92 if( a_t == NULL ) {
94 goto exit_level_0;
95 }
96 b_t = (double*)LAPACKE_malloc( sizeof(double) * ldb_t * MAX(1,n) );
97 if( b_t == NULL ) {
99 goto exit_level_1;
100 }
101 if( LAPACKE_lsame( jobvsl, 'v' ) ) {
102 vsl_t = (double*)
103 LAPACKE_malloc( sizeof(double) * ldvsl_t * MAX(1,n) );
104 if( vsl_t == NULL ) {
106 goto exit_level_2;
107 }
108 }
109 if( LAPACKE_lsame( jobvsr, 'v' ) ) {
110 vsr_t = (double*)
111 LAPACKE_malloc( sizeof(double) * ldvsr_t * MAX(1,n) );
112 if( vsr_t == NULL ) {
114 goto exit_level_3;
115 }
116 }
117 /* Transpose input matrices */
118 LAPACKE_dge_trans( matrix_layout, n, n, a, lda, a_t, lda_t );
119 LAPACKE_dge_trans( matrix_layout, n, n, b, ldb, b_t, ldb_t );
120 /* Call LAPACK function and adjust info */
121 LAPACK_dgges( &jobvsl, &jobvsr, &sort, selctg, &n, a_t, &lda_t, b_t,
122 &ldb_t, sdim, alphar, alphai, beta, vsl_t, &ldvsl_t,
123 vsr_t, &ldvsr_t, work, &lwork, bwork, &info );
124 if( info < 0 ) {
125 info = info - 1;
126 }
127 /* Transpose output matrices */
128 LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, a_t, lda_t, a, lda );
129 LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, b_t, ldb_t, b, ldb );
130 if( LAPACKE_lsame( jobvsl, 'v' ) ) {
131 LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, vsl_t, ldvsl_t, vsl,
132 ldvsl );
133 }
134 if( LAPACKE_lsame( jobvsr, 'v' ) ) {
135 LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, vsr_t, ldvsr_t, vsr,
136 ldvsr );
137 }
138 /* Release memory and exit */
139 if( LAPACKE_lsame( jobvsr, 'v' ) ) {
140 LAPACKE_free( vsr_t );
141 }
142exit_level_3:
143 if( LAPACKE_lsame( jobvsl, 'v' ) ) {
144 LAPACKE_free( vsl_t );
145 }
146exit_level_2:
147 LAPACKE_free( b_t );
148exit_level_1:
149 LAPACKE_free( a_t );
150exit_level_0:
151 if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
152 LAPACKE_xerbla( "LAPACKE_dgges_work", info );
153 }
154 } else {
155 info = -1;
156 LAPACKE_xerbla( "LAPACKE_dgges_work", info );
157 }
158 return info;
159}
#define lapack_int
Definition lapack.h:83
#define LAPACK_dgges(...)
Definition lapack.h:4395
#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