LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
lapack_int LAPACKE_cuncsd2by1_work ( int  matrix_layout,
char  jobu1,
char  jobu2,
char  jobv1t,
lapack_int  m,
lapack_int  p,
lapack_int  q,
lapack_complex_float x11,
lapack_int  ldx11,
lapack_complex_float x21,
lapack_int  ldx21,
float *  theta,
lapack_complex_float u1,
lapack_int  ldu1,
lapack_complex_float u2,
lapack_int  ldu2,
lapack_complex_float v1t,
lapack_int  ldv1t,
lapack_complex_float work,
lapack_int  lwork,
float *  rwork,
lapack_int  lrwork,
lapack_int iwork 
)

Definition at line 36 of file lapacke_cuncsd2by1_work.c.

46 {
47  lapack_int info = 0;
48  if( matrix_layout == LAPACK_COL_MAJOR ) {
49  /* Call LAPACK function and adjust info */
50  LAPACK_cuncsd2by1( &jobu1, &jobu2, &jobv1t, &m, &p,
51  &q, x11, &ldx11, x21, &ldx21,
52  theta, u1, &ldu1, u2, &ldu2, v1t, &ldv1t,
53  work, &lwork, rwork, &lrwork, iwork, &info );
54  if( info < 0 ) {
55  info = info - 1;
56  }
57  } else if( matrix_layout == LAPACK_ROW_MAJOR ) {
58  lapack_int nrows_x11 = p;
59  lapack_int nrows_x21 = m-p;
60  lapack_int nrows_u1 = ( LAPACKE_lsame( jobu1, 'y' ) ? p : 1);
61  lapack_int nrows_u2 = ( LAPACKE_lsame( jobu2, 'y' ) ? m-p : 1);
62  lapack_int nrows_v1t = ( LAPACKE_lsame( jobv1t, 'y' ) ? q : 1);
63  lapack_int ldu1_t = MAX(1,nrows_u1);
64  lapack_int ldu2_t = MAX(1,nrows_u2);
65  lapack_int ldv1t_t = MAX(1,nrows_v1t);
66  lapack_int ldx11_t = MAX(1,nrows_x11);
67  lapack_int ldx21_t = MAX(1,nrows_x21);
68  lapack_complex_float* x11_t = NULL;
69  lapack_complex_float* x21_t = NULL;
70  lapack_complex_float* u1_t = NULL;
71  lapack_complex_float* u2_t = NULL;
72  lapack_complex_float* v1t_t = NULL;
73  /* Check leading dimension(s) */
74  if( ldu1 < p ) {
75  info = -21;
76  LAPACKE_xerbla( "LAPACKE_cuncsd2by1_work", info );
77  return info;
78  }
79  if( ldu2 < m-p ) {
80  info = -23;
81  LAPACKE_xerbla( "LAPACKE_cuncsd2by1_work", info );
82  return info;
83  }
84  if( ldv1t < q ) {
85  info = -25;
86  LAPACKE_xerbla( "LAPACKE_cuncsd2by1_work", info );
87  return info;
88  }
89  if( ldx11 < q ) {
90  info = -12;
91  LAPACKE_xerbla( "LAPACKE_cuncsd2by1_work", info );
92  return info;
93  }
94  if( ldx21 < q ) {
95  info = -16;
96  LAPACKE_xerbla( "LAPACKE_cuncsd2by1_work", info );
97  return info;
98  }
99  /* Query optimal working array(s) size if requested */
100  if( lrwork == -1 || lwork == -1 ) {
101  LAPACK_cuncsd2by1( &jobu1, &jobu2, &jobv1t, &m, &p,
102  &q, x11, &ldx11_t, x21, &ldx21_t,
103  theta, u1, &ldu1_t, u2, &ldu2_t, v1t, &ldv1t_t,
104  work, &lwork, rwork, &lrwork, iwork, &info );
105  return (info < 0) ? (info - 1) : info;
106  }
107  /* Allocate memory for temporary array(s) */
108  x11_t = (lapack_complex_float*)LAPACKE_malloc( sizeof(lapack_complex_float) * ldx11_t * MAX(1,q) );
109  if( x11_t == NULL ) {
111  goto exit_level_0;
112  }
113  x21_t = (lapack_complex_float*)LAPACKE_malloc( sizeof(lapack_complex_float) * ldx21_t * MAX(1,q) );
114  if( x21_t == NULL ) {
116  goto exit_level_1;
117  }
118  if( LAPACKE_lsame( jobu1, 'y' ) ) {
119  u1_t = (lapack_complex_float*)
120  LAPACKE_malloc( sizeof(lapack_complex_float) * ldu1_t * MAX(1,p) );
121  if( u1_t == NULL ) {
123  goto exit_level_2;
124  }
125  }
126  if( LAPACKE_lsame( jobu2, 'y' ) ) {
127  u2_t = (lapack_complex_float*)
128  LAPACKE_malloc( sizeof(lapack_complex_float) * ldu2_t * MAX(1,m-p) );
129  if( u2_t == NULL ) {
131  goto exit_level_3;
132  }
133  }
134  if( LAPACKE_lsame( jobv1t, 'y' ) ) {
135  v1t_t = (lapack_complex_float*)
136  LAPACKE_malloc( sizeof(lapack_complex_float) * ldv1t_t * MAX(1,q) );
137  if( v1t_t == NULL ) {
139  goto exit_level_4;
140  }
141  }
142  /* Transpose input matrices */
143  LAPACKE_cge_trans( matrix_layout, nrows_x11, q, x11, ldx11, x11_t,
144  ldx11_t );
145  LAPACKE_cge_trans( matrix_layout, nrows_x21, q, x21, ldx21, x21_t,
146  ldx21_t );
147  /* Call LAPACK function and adjust info */
148  LAPACK_cuncsd2by1( &jobu1, &jobu2, &jobv1t, &m, &p,
149  &q, x11_t, &ldx11_t, x21_t, &ldx21_t,
150  theta, u1_t, &ldu1_t, u2_t, &ldu2_t, v1t_t, &ldv1t_t,
151  work, &lwork, rwork, &lrwork, iwork, &info );
152  if( info < 0 ) {
153  info = info - 1;
154  }
155  /* Transpose output matrices */
156  LAPACKE_cge_trans( LAPACK_COL_MAJOR, nrows_x11, q, x11_t, ldx11_t, x11,
157  ldx11 );
158  LAPACKE_cge_trans( LAPACK_COL_MAJOR, nrows_x21, q, x21_t, ldx21_t, x21,
159  ldx21 );
160  if( LAPACKE_lsame( jobu1, 'y' ) ) {
161  LAPACKE_cge_trans( LAPACK_COL_MAJOR, nrows_u1, p, u1_t, ldu1_t, u1,
162  ldu1 );
163  }
164  if( LAPACKE_lsame( jobu2, 'y' ) ) {
165  LAPACKE_cge_trans( LAPACK_COL_MAJOR, nrows_u2, m-p, u2_t, ldu2_t,
166  u2, ldu2 );
167  }
168  if( LAPACKE_lsame( jobv1t, 'y' ) ) {
169  LAPACKE_cge_trans( LAPACK_COL_MAJOR, nrows_v1t, q, v1t_t, ldv1t_t,
170  v1t, ldv1t );
171  }
172  /* Release memory and exit */
173  if( LAPACKE_lsame( jobv1t, 'y' ) ) {
174  LAPACKE_free( v1t_t );
175  }
176 exit_level_4:
177  if( LAPACKE_lsame( jobu2, 'y' ) ) {
178  LAPACKE_free( u2_t );
179  }
180 exit_level_3:
181  if( LAPACKE_lsame( jobu1, 'y' ) ) {
182  LAPACKE_free( u1_t );
183  }
184 exit_level_2:
185  LAPACKE_free( x21_t );
186 exit_level_1:
187  LAPACKE_free( x11_t );
188 exit_level_0:
189  if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
190  LAPACKE_xerbla( "LAPACKE_cuncsd2by1_work", info );
191  }
192  } else {
193  info = -1;
194  LAPACKE_xerbla( "LAPACKE_cuncsd2by1_work", info );
195  }
196  return info;
197 }
void LAPACKE_cge_trans(int matrix_layout, lapack_int m, lapack_int n, const lapack_complex_float *in, lapack_int ldin, lapack_complex_float *out, lapack_int ldout)
#define LAPACK_ROW_MAJOR
Definition: lapacke.h:119
#define lapack_complex_float
Definition: lapacke.h:74
#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_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)
void LAPACK_cuncsd2by1(char *jobu1, char *jobu2, char *jobv1t, lapack_int *m, lapack_int *p, lapack_int *q, lapack_complex_float *x11, lapack_int *ldx11, lapack_complex_float *x21, lapack_int *ldx21, float *theta, lapack_complex_float *u1, lapack_int *ldu1, lapack_complex_float *u2, lapack_int *ldu2, lapack_complex_float *v1t, lapack_int *ldv1t, lapack_complex_float *work, lapack_int *lwork, float *rwork, lapack_int *lrwork, lapack_int *iwork, lapack_int *info)
#define lapack_int
Definition: lapacke.h:47
#define LAPACK_TRANSPOSE_MEMORY_ERROR
Definition: lapacke.h:123

Here is the call graph for this function:

Here is the caller graph for this function: