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

Go to the source code of this file.

Functions

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

Function Documentation

◆ LAPACKE_dtgsna_work()

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

Definition at line 35 of file lapacke_dtgsna_work.c.

44{
45 lapack_int info = 0;
46 if( matrix_layout == LAPACK_COL_MAJOR ) {
47 /* Call LAPACK function and adjust info */
48 LAPACK_dtgsna( &job, &howmny, select, &n, a, &lda, b, &ldb, vl, &ldvl,
49 vr, &ldvr, s, dif, &mm, m, work, &lwork, iwork, &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 ldvl_t = MAX(1,n);
57 lapack_int ldvr_t = MAX(1,n);
58 double* a_t = NULL;
59 double* b_t = NULL;
60 double* vl_t = NULL;
61 double* vr_t = NULL;
62 /* Check leading dimension(s) */
63 if( lda < n ) {
64 info = -7;
65 LAPACKE_xerbla( "LAPACKE_dtgsna_work", info );
66 return info;
67 }
68 if( ldb < n ) {
69 info = -9;
70 LAPACKE_xerbla( "LAPACKE_dtgsna_work", info );
71 return info;
72 }
73 if( ldvl < mm ) {
74 info = -11;
75 LAPACKE_xerbla( "LAPACKE_dtgsna_work", info );
76 return info;
77 }
78 if( ldvr < mm ) {
79 info = -13;
80 LAPACKE_xerbla( "LAPACKE_dtgsna_work", info );
81 return info;
82 }
83 /* Query optimal working array(s) size if requested */
84 if( lwork == -1 ) {
85 LAPACK_dtgsna( &job, &howmny, select, &n, a, &lda_t, b, &ldb_t, vl,
86 &ldvl_t, vr, &ldvr_t, s, dif, &mm, m, work, &lwork,
87 iwork, &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( job, 'b' ) || LAPACKE_lsame( job, 'e' ) ) {
102 vl_t = (double*)
103 LAPACKE_malloc( sizeof(double) * ldvl_t * MAX(1,mm) );
104 if( vl_t == NULL ) {
106 goto exit_level_2;
107 }
108 }
109 if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'e' ) ) {
110 vr_t = (double*)
111 LAPACKE_malloc( sizeof(double) * ldvr_t * MAX(1,mm) );
112 if( vr_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 if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'e' ) ) {
121 LAPACKE_dge_trans( matrix_layout, n, mm, vl, ldvl, vl_t, ldvl_t );
122 }
123 if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'e' ) ) {
124 LAPACKE_dge_trans( matrix_layout, n, mm, vr, ldvr, vr_t, ldvr_t );
125 }
126 /* Call LAPACK function and adjust info */
127 LAPACK_dtgsna( &job, &howmny, select, &n, a_t, &lda_t, b_t, &ldb_t,
128 vl_t, &ldvl_t, vr_t, &ldvr_t, s, dif, &mm, m, work,
129 &lwork, iwork, &info );
130 if( info < 0 ) {
131 info = info - 1;
132 }
133 /* Release memory and exit */
134 if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'e' ) ) {
135 LAPACKE_free( vr_t );
136 }
137exit_level_3:
138 if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'e' ) ) {
139 LAPACKE_free( vl_t );
140 }
141exit_level_2:
142 LAPACKE_free( b_t );
143exit_level_1:
144 LAPACKE_free( a_t );
145exit_level_0:
146 if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
147 LAPACKE_xerbla( "LAPACKE_dtgsna_work", info );
148 }
149 } else {
150 info = -1;
151 LAPACKE_xerbla( "LAPACKE_dtgsna_work", info );
152 }
153 return info;
154}
#define LAPACK_dtgsna(...)
Definition lapack.h:20374
#define lapack_int
Definition lapack.h:83
#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