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

◆ LAPACKE_sgejsv()

lapack_int LAPACKE_sgejsv ( int  matrix_layout,
char  joba,
char  jobu,
char  jobv,
char  jobr,
char  jobt,
char  jobp,
lapack_int  m,
lapack_int  n,
float *  a,
lapack_int  lda,
float *  sva,
float *  u,
lapack_int  ldu,
float *  v,
lapack_int  ldv,
float *  stat,
lapack_int istat 
)

Definition at line 35 of file lapacke_sgejsv.c.

40{
41 lapack_int info = 0;
42 lapack_int lwork = (!( LAPACKE_lsame( jobu, 'u' ) ||
43 LAPACKE_lsame( jobu, 'f' ) ||
44 LAPACKE_lsame( jobv, 'v' ) ||
45 LAPACKE_lsame( jobv, 'j' ) ||
46 LAPACKE_lsame( joba, 'e' ) ||
47 LAPACKE_lsame( joba, 'g' ) ) ? MAX3(7,4*n+1,2*m+n) :
48 ( (!( LAPACKE_lsame( jobu, 'u' ) ||
49 LAPACKE_lsame( jobu, 'f' ) ||
50 LAPACKE_lsame( jobv, 'v' ) ||
51 LAPACKE_lsame( jobv, 'j' ) ) &&
52 ( LAPACKE_lsame( joba, 'e' ) ||
53 LAPACKE_lsame( joba, 'g' ) ) ) ? MAX3(7,4*n+n*n,2*m+n) :
54 ( ( LAPACKE_lsame( jobu, 'u' ) ||
55 LAPACKE_lsame( jobu, 'f' ) ) &&
56 (!( LAPACKE_lsame( jobv, 'v' ) ||
57 LAPACKE_lsame( jobv, 'j' ) ) ) ? MAX(7,2*n+m) :
58 ( ( LAPACKE_lsame( jobv, 'v' ) ||
59 LAPACKE_lsame( jobv, 'j' ) ) &&
60 (!( LAPACKE_lsame( jobu, 'u' ) ||
61 LAPACKE_lsame( jobu, 'f' ) ) ) ? MAX(7,2*n+m) :
62 ( ( LAPACKE_lsame( jobu, 'u' ) ||
63 LAPACKE_lsame( jobu, 'f' ) ) &&
64 ( LAPACKE_lsame( jobv, 'v' ) ||
65 LAPACKE_lsame( jobv, 'j' ) ) &&
66 !LAPACKE_lsame( jobv, 'j' ) ? MAX(1,6*n+2*n*n) :
67 ( ( LAPACKE_lsame( jobu, 'u' ) ||
68 LAPACKE_lsame( jobu, 'f' ) ) &&
69 ( LAPACKE_lsame( jobv, 'v' ) ||
70 LAPACKE_lsame( jobv, 'j' ) ) &&
71 LAPACKE_lsame( jobv, 'j' ) ? MAX(7,m+3*n+n*n) :
72 7) ) ) ) ) );
73 lapack_int* iwork = NULL;
74 float* work = NULL;
75 lapack_int i;
76 if( matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR ) {
77 LAPACKE_xerbla( "LAPACKE_sgejsv", -1 );
78 return -1;
79 }
80#ifndef LAPACK_DISABLE_NAN_CHECK
81 if( LAPACKE_get_nancheck() ) {
82 /* Optionally check input matrices for NaNs */
83 if( LAPACKE_sge_nancheck( matrix_layout, m, n, a, lda ) ) {
84 return -10;
85 }
86 }
87#endif
88 /* Allocate memory for working array(s) */
89 iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * MAX(3,m+3*n) );
90 if( iwork == NULL ) {
92 goto exit_level_0;
93 }
94 lwork = MAX3( lwork, 7, 2*m+n );
95 { /* FIXUP LWORK */
96 int want_u = LAPACKE_lsame( jobu, 'u' ) || LAPACKE_lsame( jobu, 'f' );
97 int want_v = LAPACKE_lsame( jobv, 'v' ) || LAPACKE_lsame( jobv, 'j' );
98 int want_sce = LAPACKE_lsame( joba, 'e' ) || LAPACKE_lsame( joba, 'g' );
99 if( !want_u && !want_v && !want_sce ) lwork = MAX( lwork, 4*n+1 ); // 1.1
100 if( !want_u && !want_v && want_sce ) lwork = MAX( lwork, n*n+4*n ); // 1.2
101 if( !want_u && want_v ) lwork = MAX( lwork, 4*n+1 ); // 2
102 if( want_u && !want_v ) lwork = MAX( lwork, 4*n+1 ); // 3
103 if( want_u && LAPACKE_lsame( jobv, 'v' ) ) lwork = MAX( lwork, 6*n+2*n*n ); // 4.1
104 if( want_u && LAPACKE_lsame( jobv, 'j' ) ) lwork = MAX3( lwork, 4*n+n*n, 2*n+n*n+6 ); // 4.2
105 }
106 work = (float*)LAPACKE_malloc( sizeof(float) * lwork );
107 if( work == NULL ) {
109 goto exit_level_1;
110 }
111 /* Call middle-level interface */
112 info = LAPACKE_sgejsv_work( matrix_layout, joba, jobu, jobv, jobr, jobt,
113 jobp, m, n, a, lda, sva, u, ldu, v, ldv, work,
114 lwork, iwork );
115 /* Backup significant data from working array(s) */
116 for( i=0; i<7; i++ ) {
117 stat[i] = work[i];
118 }
119 for( i=0; i<3; i++ ) {
120 istat[i] = iwork[i];
121 }
122 /* Release memory and exit */
123 LAPACKE_free( work );
124exit_level_1:
125 LAPACKE_free( iwork );
126exit_level_0:
127 if( info == LAPACK_WORK_MEMORY_ERROR ) {
128 LAPACKE_xerbla( "LAPACKE_sgejsv", info );
129 }
130 return info;
131}
#define lapack_int
Definition: lapack.h:87
#define LAPACK_WORK_MEMORY_ERROR
Definition: lapacke.h:55
#define LAPACK_COL_MAJOR
Definition: lapacke.h:53
#define LAPACKE_free(p)
Definition: lapacke.h:46
#define LAPACK_ROW_MAJOR
Definition: lapacke.h:52
int LAPACKE_get_nancheck(void)
lapack_int LAPACKE_sgejsv_work(int matrix_layout, char joba, char jobu, char jobv, char jobr, char jobt, char jobp, lapack_int m, lapack_int n, float *a, lapack_int lda, float *sva, float *u, lapack_int ldu, float *v, lapack_int ldv, float *work, lapack_int lwork, lapack_int *iwork)
#define LAPACKE_malloc(size)
Definition: lapacke.h:43
lapack_logical LAPACKE_lsame(char ca, char cb)
Definition: lapacke_lsame.c:35
void LAPACKE_xerbla(const char *name, lapack_int info)
lapack_logical LAPACKE_sge_nancheck(int matrix_layout, lapack_int m, lapack_int n, const float *a, lapack_int lda)
#define MAX3(x, y, z)
Definition: lapacke_utils.h:52
#define MAX(x, y)
Definition: lapacke_utils.h:46
Here is the call graph for this function: