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

◆ LAPACKE_stgsna_work()

lapack_int LAPACKE_stgsna_work ( int  matrix_layout,
char  job,
char  howmny,
const lapack_logical select,
lapack_int  n,
const float *  a,
lapack_int  lda,
const float *  b,
lapack_int  ldb,
const float *  vl,
lapack_int  ldvl,
const float *  vr,
lapack_int  ldvr,
float *  s,
float *  dif,
lapack_int  mm,
lapack_int m,
float *  work,
lapack_int  lwork,
lapack_int iwork 
)

Definition at line 35 of file lapacke_stgsna_work.c.

43{
44 lapack_int info = 0;
45 if( matrix_layout == LAPACK_COL_MAJOR ) {
46 /* Call LAPACK function and adjust info */
47 LAPACK_stgsna( &job, &howmny, select, &n, a, &lda, b, &ldb, vl, &ldvl,
48 vr, &ldvr, s, dif, &mm, m, work, &lwork, iwork, &info );
49 if( info < 0 ) {
50 info = info - 1;
51 }
52 } else if( matrix_layout == LAPACK_ROW_MAJOR ) {
53 lapack_int lda_t = MAX(1,n);
54 lapack_int ldb_t = MAX(1,n);
55 lapack_int ldvl_t = MAX(1,n);
56 lapack_int ldvr_t = MAX(1,n);
57 float* a_t = NULL;
58 float* b_t = NULL;
59 float* vl_t = NULL;
60 float* vr_t = NULL;
61 /* Check leading dimension(s) */
62 if( lda < n ) {
63 info = -7;
64 LAPACKE_xerbla( "LAPACKE_stgsna_work", info );
65 return info;
66 }
67 if( ldb < n ) {
68 info = -9;
69 LAPACKE_xerbla( "LAPACKE_stgsna_work", info );
70 return info;
71 }
72 if( ldvl < mm ) {
73 info = -11;
74 LAPACKE_xerbla( "LAPACKE_stgsna_work", info );
75 return info;
76 }
77 if( ldvr < mm ) {
78 info = -13;
79 LAPACKE_xerbla( "LAPACKE_stgsna_work", info );
80 return info;
81 }
82 /* Query optimal working array(s) size if requested */
83 if( lwork == -1 ) {
84 LAPACK_stgsna( &job, &howmny, select, &n, a, &lda_t, b, &ldb_t, vl,
85 &ldvl_t, vr, &ldvr_t, s, dif, &mm, m, work, &lwork,
86 iwork, &info );
87 return (info < 0) ? (info - 1) : info;
88 }
89 /* Allocate memory for temporary array(s) */
90 a_t = (float*)LAPACKE_malloc( sizeof(float) * lda_t * MAX(1,n) );
91 if( a_t == NULL ) {
93 goto exit_level_0;
94 }
95 b_t = (float*)LAPACKE_malloc( sizeof(float) * ldb_t * MAX(1,n) );
96 if( b_t == NULL ) {
98 goto exit_level_1;
99 }
100 if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'e' ) ) {
101 vl_t = (float*)LAPACKE_malloc( sizeof(float) * ldvl_t * MAX(1,mm) );
102 if( vl_t == NULL ) {
104 goto exit_level_2;
105 }
106 }
107 if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'e' ) ) {
108 vr_t = (float*)LAPACKE_malloc( sizeof(float) * ldvr_t * MAX(1,mm) );
109 if( vr_t == NULL ) {
111 goto exit_level_3;
112 }
113 }
114 /* Transpose input matrices */
115 LAPACKE_sge_trans( matrix_layout, n, n, a, lda, a_t, lda_t );
116 LAPACKE_sge_trans( matrix_layout, n, n, b, ldb, b_t, ldb_t );
117 if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'e' ) ) {
118 LAPACKE_sge_trans( matrix_layout, n, mm, vl, ldvl, vl_t, ldvl_t );
119 }
120 if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'e' ) ) {
121 LAPACKE_sge_trans( matrix_layout, n, mm, vr, ldvr, vr_t, ldvr_t );
122 }
123 /* Call LAPACK function and adjust info */
124 LAPACK_stgsna( &job, &howmny, select, &n, a_t, &lda_t, b_t, &ldb_t,
125 vl_t, &ldvl_t, vr_t, &ldvr_t, s, dif, &mm, m, work,
126 &lwork, iwork, &info );
127 if( info < 0 ) {
128 info = info - 1;
129 }
130 /* Release memory and exit */
131 if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'e' ) ) {
132 LAPACKE_free( vr_t );
133 }
134exit_level_3:
135 if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'e' ) ) {
136 LAPACKE_free( vl_t );
137 }
138exit_level_2:
139 LAPACKE_free( b_t );
140exit_level_1:
141 LAPACKE_free( a_t );
142exit_level_0:
143 if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
144 LAPACKE_xerbla( "LAPACKE_stgsna_work", info );
145 }
146 } else {
147 info = -1;
148 LAPACKE_xerbla( "LAPACKE_stgsna_work", info );
149 }
150 return info;
151}
#define lapack_int
Definition: lapack.h:87
#define LAPACK_stgsna(...)
Definition: lapack.h:20414
#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: