LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
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 36 of file lapacke_sgejsv.c.

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

Here is the call graph for this function: