LAPACK 3.11.0
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ LAPACKE_sgges_work()

lapack_int LAPACKE_sgges_work ( int  matrix_layout,
char  jobvsl,
char  jobvsr,
char  sort,
LAPACK_S_SELECT3  selctg,
lapack_int  n,
float *  a,
lapack_int  lda,
float *  b,
lapack_int  ldb,
lapack_int sdim,
float *  alphar,
float *  alphai,
float *  beta,
float *  vsl,
lapack_int  ldvsl,
float *  vsr,
lapack_int  ldvsr,
float *  work,
lapack_int  lwork,
lapack_logical bwork 
)

Definition at line 35 of file lapacke_sgges_work.c.

43{
44 lapack_int info = 0;
45 if( matrix_layout == LAPACK_COL_MAJOR ) {
46 /* Call LAPACK function and adjust info */
47 LAPACK_sgges( &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 float* a_t = NULL;
59 float* b_t = NULL;
60 float* vsl_t = NULL;
61 float* vsr_t = NULL;
62 /* Check leading dimension(s) */
63 if( lda < n ) {
64 info = -8;
65 LAPACKE_xerbla( "LAPACKE_sgges_work", info );
66 return info;
67 }
68 if( ldb < n ) {
69 info = -10;
70 LAPACKE_xerbla( "LAPACKE_sgges_work", info );
71 return info;
72 }
73 if( ldvsl < 1 || ( LAPACKE_lsame( jobvsl, 'v' ) && ldvsl < n ) ) {
74 info = -16;
75 LAPACKE_xerbla( "LAPACKE_sgges_work", info );
76 return info;
77 }
78 if( ldvsr < 1 || ( LAPACKE_lsame( jobvsr, 'v' ) && ldvsr < n ) ) {
79 info = -18;
80 LAPACKE_xerbla( "LAPACKE_sgges_work", info );
81 return info;
82 }
83 /* Query optimal working array(s) size if requested */
84 if( lwork == -1 ) {
85 LAPACK_sgges( &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 = (float*)LAPACKE_malloc( sizeof(float) * lda_t * MAX(1,n) );
92 if( a_t == NULL ) {
94 goto exit_level_0;
95 }
96 b_t = (float*)LAPACKE_malloc( sizeof(float) * 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 = (float*)
103 LAPACKE_malloc( sizeof(float) * 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 = (float*)
111 LAPACKE_malloc( sizeof(float) * ldvsr_t * MAX(1,n) );
112 if( vsr_t == NULL ) {
114 goto exit_level_3;
115 }
116 }
117 /* Transpose input matrices */
118 LAPACKE_sge_trans( matrix_layout, n, n, a, lda, a_t, lda_t );
119 LAPACKE_sge_trans( matrix_layout, n, n, b, ldb, b_t, ldb_t );
120 /* Call LAPACK function and adjust info */
121 LAPACK_sgges( &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_sge_trans( LAPACK_COL_MAJOR, n, n, a_t, lda_t, a, lda );
129 LAPACKE_sge_trans( LAPACK_COL_MAJOR, n, n, b_t, ldb_t, b, ldb );
130 if( LAPACKE_lsame( jobvsl, 'v' ) ) {
131 LAPACKE_sge_trans( LAPACK_COL_MAJOR, n, n, vsl_t, ldvsl_t, vsl,
132 ldvsl );
133 }
134 if( LAPACKE_lsame( jobvsr, 'v' ) ) {
135 LAPACKE_sge_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_sgges_work", info );
153 }
154 } else {
155 info = -1;
156 LAPACKE_xerbla( "LAPACKE_sgges_work", info );
157 }
158 return info;
159}
#define LAPACK_sgges(...)
Definition: lapack.h:4434
#define lapack_int
Definition: lapack.h:87
#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)
void LAPACKE_sge_trans(int matrix_layout, lapack_int m, lapack_int n, const float *in, lapack_int ldin, float *out, lapack_int ldout)
#define MAX(x, y)
Definition: lapacke_utils.h:46
Here is the call graph for this function:
Here is the caller graph for this function: