LAPACK  3.10.0
LAPACK: Linear Algebra PACKage

◆ LAPACKE_dggsvp3_work()

lapack_int LAPACKE_dggsvp3_work ( int  matrix_layout,
char  jobu,
char  jobv,
char  jobq,
lapack_int  m,
lapack_int  p,
lapack_int  n,
double *  a,
lapack_int  lda,
double *  b,
lapack_int  ldb,
double  tola,
double  tolb,
lapack_int k,
lapack_int l,
double *  u,
lapack_int  ldu,
double *  v,
lapack_int  ldv,
double *  q,
lapack_int  ldq,
lapack_int iwork,
double *  tau,
double *  work,
lapack_int  lwork 
)

Definition at line 35 of file lapacke_dggsvp3_work.c.

44 {
45  lapack_int info = 0;
46  if( matrix_layout == LAPACK_COL_MAJOR ) {
47  /* Call LAPACK function and adjust info */
48  LAPACK_dggsvp3( &jobu, &jobv, &jobq, &m, &p, &n, a, &lda, b, &ldb, &tola,
49  &tolb, k, l, u, &ldu, v, &ldv, q, &ldq, iwork, tau, work,
50  &lwork, &info );
51  if( info < 0 ) {
52  info = info - 1;
53  }
54  } else if( matrix_layout == LAPACK_ROW_MAJOR ) {
55  lapack_int lda_t = MAX(1,m);
56  lapack_int ldb_t = MAX(1,p);
57  lapack_int ldq_t = MAX(1,n);
58  lapack_int ldu_t = MAX(1,m);
59  lapack_int ldv_t = MAX(1,p);
60  double* a_t = NULL;
61  double* b_t = NULL;
62  double* u_t = NULL;
63  double* v_t = NULL;
64  double* q_t = NULL;
65  /* Check leading dimension(s) */
66  if( lda < n ) {
67  info = -9;
68  LAPACKE_xerbla( "LAPACKE_dggsvp3_work", info );
69  return info;
70  }
71  if( ldb < n ) {
72  info = -11;
73  LAPACKE_xerbla( "LAPACKE_dggsvp3_work", info );
74  return info;
75  }
76  if( ldq < n ) {
77  info = -21;
78  LAPACKE_xerbla( "LAPACKE_dggsvp3_work", info );
79  return info;
80  }
81  if( ldu < m ) {
82  info = -17;
83  LAPACKE_xerbla( "LAPACKE_dggsvp3_work", info );
84  return info;
85  }
86  if( ldv < p ) {
87  info = -19;
88  LAPACKE_xerbla( "LAPACKE_dggsvp3_work", info );
89  return info;
90  }
91  if( lwork == -1 ) {
92  LAPACK_dggsvp3( &jobu, &jobv, &jobq, &m, &p, &n, a, &lda_t, b,
93  &ldb_t, &tola, &tolb, k, l, u, &ldu_t, v,
94  &ldv_t, q, &ldq_t, iwork, tau, work, &lwork,
95  &info );
96  return (info < 0) ? (info - 1) : info;
97  }
98  /* Allocate memory for temporary array(s) */
99  a_t = (double*)LAPACKE_malloc( sizeof(double) * lda_t * MAX(1,n) );
100  if( a_t == NULL ) {
102  goto exit_level_0;
103  }
104  b_t = (double*)LAPACKE_malloc( sizeof(double) * ldb_t * MAX(1,n) );
105  if( b_t == NULL ) {
107  goto exit_level_1;
108  }
109  if( LAPACKE_lsame( jobu, 'u' ) ) {
110  u_t = (double*)LAPACKE_malloc( sizeof(double) * ldu_t * MAX(1,m) );
111  if( u_t == NULL ) {
113  goto exit_level_2;
114  }
115  }
116  if( LAPACKE_lsame( jobv, 'v' ) ) {
117  v_t = (double*)LAPACKE_malloc( sizeof(double) * ldv_t * MAX(1,p) );
118  if( v_t == NULL ) {
120  goto exit_level_3;
121  }
122  }
123  if( LAPACKE_lsame( jobq, 'q' ) ) {
124  q_t = (double*)LAPACKE_malloc( sizeof(double) * ldq_t * MAX(1,n) );
125  if( q_t == NULL ) {
127  goto exit_level_4;
128  }
129  }
130  /* Transpose input matrices */
131  LAPACKE_dge_trans( matrix_layout, m, n, a, lda, a_t, lda_t );
132  LAPACKE_dge_trans( matrix_layout, p, n, b, ldb, b_t, ldb_t );
133  /* Call LAPACK function and adjust info */
134  LAPACK_dggsvp3( &jobu, &jobv, &jobq, &m, &p, &n, a_t, &lda_t, b_t,
135  &ldb_t, &tola, &tolb, k, l, u_t, &ldu_t, v_t, &ldv_t,
136  q_t, &ldq_t, iwork, tau, work, &lwork, &info );
137  if( info < 0 ) {
138  info = info - 1;
139  }
140  /* Transpose output matrices */
141  LAPACKE_dge_trans( LAPACK_COL_MAJOR, m, n, a_t, lda_t, a, lda );
142  LAPACKE_dge_trans( LAPACK_COL_MAJOR, p, n, b_t, ldb_t, b, ldb );
143  if( LAPACKE_lsame( jobu, 'u' ) ) {
144  LAPACKE_dge_trans( LAPACK_COL_MAJOR, m, m, u_t, ldu_t, u, ldu );
145  }
146  if( LAPACKE_lsame( jobv, 'v' ) ) {
147  LAPACKE_dge_trans( LAPACK_COL_MAJOR, p, p, v_t, ldv_t, v, ldv );
148  }
149  if( LAPACKE_lsame( jobq, 'q' ) ) {
150  LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, q_t, ldq_t, q, ldq );
151  }
152  /* Release memory and exit */
153  if( LAPACKE_lsame( jobq, 'q' ) ) {
154  LAPACKE_free( q_t );
155  }
156 exit_level_4:
157  if( LAPACKE_lsame( jobv, 'v' ) ) {
158  LAPACKE_free( v_t );
159  }
160 exit_level_3:
161  if( LAPACKE_lsame( jobu, 'u' ) ) {
162  LAPACKE_free( u_t );
163  }
164 exit_level_2:
165  LAPACKE_free( b_t );
166 exit_level_1:
167  LAPACKE_free( a_t );
168 exit_level_0:
169  if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
170  LAPACKE_xerbla( "LAPACKE_dggsvp3_work", info );
171  }
172  } else {
173  info = -1;
174  LAPACKE_xerbla( "LAPACKE_dggsvp3_work", info );
175  }
176  return info;
177 }
#define lapack_int
Definition: lapack.h:83
#define LAPACK_dggsvp3(...)
Definition: lapack.h:5594
#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)
Definition: lapacke_lsame.c:35
void LAPACKE_xerbla(const char *name, lapack_int info)
#define MAX(x, y)
Definition: lapacke_utils.h:46
void LAPACKE_dge_trans(int matrix_layout, lapack_int m, lapack_int n, const double *in, lapack_int ldin, double *out, lapack_int ldout)
Here is the call graph for this function:
Here is the caller graph for this function: