LAPACK  3.10.0
LAPACK: Linear Algebra PACKage

◆ LAPACKE_zgejsv()

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

Definition at line 35 of file lapacke_zgejsv.c.

40 {
41  lapack_int info = 0;
42  lapack_int lwork = (
43  // 1.1
44  ( LAPACKE_lsame( jobu, 'n' ) && LAPACKE_lsame( jobv, 'n' ) &&
45  ( LAPACKE_lsame( jobt, 't' ) || LAPACKE_lsame( joba, 'f' ) || LAPACKE_lsame( joba, 'g' ) )) ? 2*n+1 :
46 
47  //1.2
48  ( ( LAPACKE_lsame( jobu, 'n' ) && LAPACKE_lsame( jobv, 'n' ) &&
49  !( LAPACKE_lsame( jobt, 't' ) || LAPACKE_lsame( joba, 'f' ) || LAPACKE_lsame( joba, 'g' ) )) ? n*n+3*n :
50 
51  //2.1
52  ( ( ( LAPACKE_lsame( jobv, 'v' ) || LAPACKE_lsame( jobv, 'j' ) ) &&
53  !( LAPACKE_lsame( jobu, 'u') || LAPACKE_lsame( jobu, 'f' ) )&&
54  ( LAPACKE_lsame( jobt, 't' ) || LAPACKE_lsame( joba, 'f' ) || LAPACKE_lsame( joba, 'g' ) ))? 3*n :
55 
56 
57  //2.2
58  ( ( ( LAPACKE_lsame( jobv, 'v' ) || LAPACKE_lsame( jobv, 'j' ) ) &&
59  !( LAPACKE_lsame( jobu, 'u' ) || LAPACKE_lsame( jobu, 'f' ) ) &&
60  !( LAPACKE_lsame( jobt, 't' ) || LAPACKE_lsame( joba, 'f' ) || LAPACKE_lsame( joba, 'g' ) ))? 3*n :
61 
62  //3.1
63  ( ( ( LAPACKE_lsame( jobu, 'u' ) || LAPACKE_lsame( jobu, 'f' )) &&
64  !( LAPACKE_lsame( jobv, 'v' ) || LAPACKE_lsame( jobv, 'j' )) &&
65  ( LAPACKE_lsame( jobt, 't' ) || LAPACKE_lsame( joba, 'f' ) || LAPACKE_lsame( joba, 'g' ) ))? 3*n :
66 
67  //3.2
68  ( ( ( LAPACKE_lsame( jobu, 'u' ) || LAPACKE_lsame( jobu, 'f' )) &&
69  !(LAPACKE_lsame( jobv, 'v' ) || LAPACKE_lsame( jobv, 'j' )) &&
70  !(LAPACKE_lsame( jobt, 't' ) || LAPACKE_lsame( joba, 'f' ) || LAPACKE_lsame( joba, 'g' ) ))? 3*n :
71 
72  //4.1
73  ( ( ( LAPACKE_lsame( jobu, 'u' ) || LAPACKE_lsame( jobu, 'f' ) ) &&
74  ( LAPACKE_lsame( jobv, 'v' ) || LAPACKE_lsame( jobv, 'j' ) ) &&
75  ( LAPACKE_lsame( jobt, 't' ) || LAPACKE_lsame( joba, 'f' ) || LAPACKE_lsame( joba, 'g' ) ))? 5*n+2*n*n :
76 
77  //4.2
78  ( ( ( LAPACKE_lsame( jobu, 'u' ) || LAPACKE_lsame( jobu, 'f' ) ) &&
79  ( LAPACKE_lsame( jobv, 'v' ) || LAPACKE_lsame( jobv, 'j' ) ) &&
80  ( LAPACKE_lsame( jobt, 't' ) || LAPACKE_lsame( joba, 'f' ) || LAPACKE_lsame( joba, 'g' ) ))? 4*n*n:
81  1) ) ) ) ) ) ) );
82  lapack_int lrwork = (
83  // 1.1
84  ( LAPACKE_lsame( jobu, 'n' ) && LAPACKE_lsame( jobv, 'n' ) &&
85  ( LAPACKE_lsame( jobt, 't' ) || LAPACKE_lsame( joba, 'f' ) || LAPACKE_lsame( joba, 'g' ) )) ? MAX(7,n+2*m) :
86 
87  //1.2
88  ( ( LAPACKE_lsame( jobu, 'n' ) && LAPACKE_lsame( jobv, 'n' ) &&
89  !( LAPACKE_lsame( jobt, 't' ) || LAPACKE_lsame( joba, 'f' ) || LAPACKE_lsame( joba, 'g' ) )) ? MAX(7,2*n) :
90 
91  //2.1
92  ( ( ( LAPACKE_lsame( jobv, 'v' ) || LAPACKE_lsame( jobv, 'j' ) ) &&
93  !( LAPACKE_lsame( jobu, 'u') || LAPACKE_lsame( jobu, 'f' ) ) &&
94  ( LAPACKE_lsame( jobt, 't' ) || LAPACKE_lsame( joba, 'f' ) || LAPACKE_lsame( joba, 'g' ) ))? MAX( 7, n+ 2*m ) :
95 
96 
97  //2.2
98  ( ( ( LAPACKE_lsame( jobv, 'v' ) || LAPACKE_lsame( jobv, 'j' ) ) &&
99  !( LAPACKE_lsame( jobu, 'u' ) || LAPACKE_lsame( jobu, 'f' ) ) &&
100  !( LAPACKE_lsame( jobt, 't' ) || LAPACKE_lsame( joba, 'f' ) || LAPACKE_lsame( joba, 'g' ) ))? MAX(7,2*n) :
101 
102  //3.1
103  ( ( ( LAPACKE_lsame( jobu, 'u' ) || LAPACKE_lsame( jobu, 'f' )) &&
104  !( LAPACKE_lsame( jobv, 'v' ) || LAPACKE_lsame( jobv, 'j' )) &&
105  ( LAPACKE_lsame( jobt, 't' ) || LAPACKE_lsame( joba, 'f' ) || LAPACKE_lsame( joba, 'g' ) ))? MAX( 7, n+ 2*m ) :
106 
107  //3.2
108  ( ( ( LAPACKE_lsame( jobu, 'u' ) || LAPACKE_lsame( jobu, 'f' )) &&
109  !(LAPACKE_lsame( jobv, 'v' ) || LAPACKE_lsame( jobv, 'j' )) &&
110  !(LAPACKE_lsame( jobt, 't' ) || LAPACKE_lsame( joba, 'f' ) || LAPACKE_lsame( joba, 'g' ) ))? MAX(7,2*n) :
111 
112  //4.1
113  ( ( ( LAPACKE_lsame( jobu, 'u' ) || LAPACKE_lsame( jobu, 'f' ) ) &&
114  ( LAPACKE_lsame( jobv, 'v' ) || LAPACKE_lsame( jobv, 'j' ) ) &&
115  ( LAPACKE_lsame( jobt, 't' ) || LAPACKE_lsame( joba, 'f' ) || LAPACKE_lsame( joba, 'g' ) ))? MAX( 7, n+ 2*m ) :
116 
117  //4.2
118  ( ( ( LAPACKE_lsame( jobu, 'u' ) || LAPACKE_lsame( jobu, 'f' ) ) &&
119  ( LAPACKE_lsame( jobv, 'v' ) || LAPACKE_lsame( jobv, 'j' ) ) &&
120  ( LAPACKE_lsame( jobt, 't' ) || LAPACKE_lsame( joba, 'f' ) || LAPACKE_lsame( joba, 'g' ) ))? MAX(7,2*n) :
121  7) ) ) ) ) ) ) );
122  lapack_int* iwork = NULL;
123  double* rwork = NULL;
124  lapack_complex_double* cwork = NULL;
125  lapack_int i;
126  if( matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR ) {
127  LAPACKE_xerbla( "LAPACKE_zgejsv", -1 );
128  return -1;
129  }
130 #ifndef LAPACK_DISABLE_NAN_CHECK
131  if( LAPACKE_get_nancheck() ) {
132  /* Optionally check input matrices for NaNs */
133  if( LAPACKE_zge_nancheck( matrix_layout, m, n, a, lda ) ) {
134  return -10;
135  }
136  }
137 #endif
138  /* Allocate memory for working array(s) */
139  iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * MAX(3,m+2*n) );
140  if( iwork == NULL ) {
142  goto exit_level_0;
143  }
144  lwork = MAX( lwork, 1 );
145  { /* FIXUP LWORK */
146  int want_u = LAPACKE_lsame( jobu, 'u' ) || LAPACKE_lsame( jobu, 'f' );
147  int want_v = LAPACKE_lsame( jobv, 'v' ) || LAPACKE_lsame( jobv, 'j' );
148  int want_sce = LAPACKE_lsame( joba, 'e' ) || LAPACKE_lsame( joba, 'g' );
149  if( !want_u && !want_v && !want_sce ) lwork = MAX( lwork, 2*n+1 ); // 1.1
150  if( !want_u && !want_v && want_sce ) lwork = MAX( lwork, n*n+3*n ); // 1.2
151  if( want_u && LAPACKE_lsame( jobv, 'v' ) ) lwork = MAX( lwork, 5*n+2*n*n ); // 4.1
152  if( want_u && LAPACKE_lsame( jobv, 'j' ) ) lwork = MAX( lwork, 4*n+n*n ); // 4.2
153  }
154  cwork = (lapack_complex_double*)LAPACKE_malloc( sizeof(lapack_complex_double) * lwork );
155  if( cwork == NULL ) {
157  goto exit_level_1;
158  }
159  lrwork = MAX3( lrwork, 7, n+2*m );
160  rwork = (double*)LAPACKE_malloc( sizeof(double) * lrwork );
161  if( rwork == NULL ) {
163  goto exit_level_2;
164  }
165  /* Call middle-level interface */
166  info = LAPACKE_zgejsv_work( matrix_layout, joba, jobu, jobv, jobr, jobt,
167  jobp, m, n, a, lda, sva, u, ldu, v, ldv, cwork,
168  lwork, rwork, lrwork, iwork );
169  /* Backup significant data from working array(s) */
170  for( i=0; i<7; i++ ) {
171  stat[i] = rwork[i];
172  }
173  for( i=0; i<3; i++ ) {
174  istat[i] = iwork[i];
175  }
176  /* Release memory and exit */
177  LAPACKE_free( cwork );
178 exit_level_2:
179  LAPACKE_free( rwork );
180 exit_level_1:
181  LAPACKE_free( iwork );
182 exit_level_0:
183  if( info == LAPACK_WORK_MEMORY_ERROR ) {
184  LAPACKE_xerbla( "LAPACKE_zgejsv", info );
185  }
186  return info;
187 }
#define lapack_int
Definition: lapack.h:83
#define lapack_complex_double
Definition: lapack.h:63
#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)
#define LAPACKE_malloc(size)
Definition: lapacke.h:43
lapack_int LAPACKE_zgejsv_work(int matrix_layout, char joba, char jobu, char jobv, char jobr, char jobt, char jobp, lapack_int m, lapack_int n, lapack_complex_double *a, lapack_int lda, double *sva, lapack_complex_double *u, lapack_int ldu, lapack_complex_double *v, lapack_int ldv, lapack_complex_double *cwork, lapack_int lwork, double *work, lapack_int lrwork, lapack_int *iwork)
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_zge_nancheck(int matrix_layout, lapack_int m, lapack_int n, const lapack_complex_double *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: