LAPACK  3.10.0
LAPACK: Linear Algebra PACKage

◆ LAPACKE_dggsvd_work()

lapack_int LAPACKE_dggsvd_work ( int  matrix_layout,
char  jobu,
char  jobv,
char  jobq,
lapack_int  m,
lapack_int  n,
lapack_int  p,
lapack_int k,
lapack_int l,
double *  a,
lapack_int  lda,
double *  b,
lapack_int  ldb,
double *  alpha,
double *  beta,
double *  u,
lapack_int  ldu,
double *  v,
lapack_int  ldv,
double *  q,
lapack_int  ldq,
double *  work,
lapack_int iwork 
)

Definition at line 35 of file lapacke_dggsvd_work.c.

43 {
44  lapack_int info = 0;
45  if( matrix_layout == LAPACK_COL_MAJOR ) {
46  /* Call LAPACK function and adjust info */
47  LAPACK_dggsvd( &jobu, &jobv, &jobq, &m, &n, &p, k, l, a, &lda, b, &ldb,
48  alpha, beta, u, &ldu, v, &ldv, q, &ldq, work, iwork,
49  &info );
50  if( info < 0 ) {
51  info = info - 1;
52  }
53  } else if( matrix_layout == LAPACK_ROW_MAJOR ) {
54  lapack_int lda_t = MAX(1,m);
55  lapack_int ldb_t = MAX(1,p);
56  lapack_int ldq_t = MAX(1,n);
57  lapack_int ldu_t = MAX(1,m);
58  lapack_int ldv_t = MAX(1,p);
59  double* a_t = NULL;
60  double* b_t = NULL;
61  double* u_t = NULL;
62  double* v_t = NULL;
63  double* q_t = NULL;
64  /* Check leading dimension(s) */
65  if( lda < n ) {
66  info = -11;
67  LAPACKE_xerbla( "LAPACKE_dggsvd_work", info );
68  return info;
69  }
70  if( ldb < n ) {
71  info = -13;
72  LAPACKE_xerbla( "LAPACKE_dggsvd_work", info );
73  return info;
74  }
75  if( ldq < n ) {
76  info = -21;
77  LAPACKE_xerbla( "LAPACKE_dggsvd_work", info );
78  return info;
79  }
80  if( ldu < m ) {
81  info = -17;
82  LAPACKE_xerbla( "LAPACKE_dggsvd_work", info );
83  return info;
84  }
85  if( ldv < p ) {
86  info = -19;
87  LAPACKE_xerbla( "LAPACKE_dggsvd_work", info );
88  return info;
89  }
90  /* Allocate memory for temporary array(s) */
91  a_t = (double*)LAPACKE_malloc( sizeof(double) * lda_t * MAX(1,n) );
92  if( a_t == NULL ) {
94  goto exit_level_0;
95  }
96  b_t = (double*)LAPACKE_malloc( sizeof(double) * ldb_t * MAX(1,n) );
97  if( b_t == NULL ) {
99  goto exit_level_1;
100  }
101  if( LAPACKE_lsame( jobu, 'u' ) ) {
102  u_t = (double*)LAPACKE_malloc( sizeof(double) * ldu_t * MAX(1,m) );
103  if( u_t == NULL ) {
105  goto exit_level_2;
106  }
107  }
108  if( LAPACKE_lsame( jobv, 'v' ) ) {
109  v_t = (double*)LAPACKE_malloc( sizeof(double) * ldv_t * MAX(1,p) );
110  if( v_t == NULL ) {
112  goto exit_level_3;
113  }
114  }
115  if( LAPACKE_lsame( jobq, 'q' ) ) {
116  q_t = (double*)LAPACKE_malloc( sizeof(double) * ldq_t * MAX(1,n) );
117  if( q_t == NULL ) {
119  goto exit_level_4;
120  }
121  }
122  /* Transpose input matrices */
123  LAPACKE_dge_trans( matrix_layout, m, n, a, lda, a_t, lda_t );
124  LAPACKE_dge_trans( matrix_layout, p, n, b, ldb, b_t, ldb_t );
125  /* Call LAPACK function and adjust info */
126  LAPACK_dggsvd( &jobu, &jobv, &jobq, &m, &n, &p, k, l, a_t, &lda_t, b_t,
127  &ldb_t, alpha, beta, u_t, &ldu_t, v_t, &ldv_t, q_t,
128  &ldq_t, work, iwork, &info );
129  if( info < 0 ) {
130  info = info - 1;
131  }
132  /* Transpose output matrices */
133  LAPACKE_dge_trans( LAPACK_COL_MAJOR, m, n, a_t, lda_t, a, lda );
134  LAPACKE_dge_trans( LAPACK_COL_MAJOR, p, n, b_t, ldb_t, b, ldb );
135  if( LAPACKE_lsame( jobu, 'u' ) ) {
136  LAPACKE_dge_trans( LAPACK_COL_MAJOR, m, m, u_t, ldu_t, u, ldu );
137  }
138  if( LAPACKE_lsame( jobv, 'v' ) ) {
139  LAPACKE_dge_trans( LAPACK_COL_MAJOR, p, p, v_t, ldv_t, v, ldv );
140  }
141  if( LAPACKE_lsame( jobq, 'q' ) ) {
142  LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, q_t, ldq_t, q, ldq );
143  }
144  /* Release memory and exit */
145  if( LAPACKE_lsame( jobq, 'q' ) ) {
146  LAPACKE_free( q_t );
147  }
148 exit_level_4:
149  if( LAPACKE_lsame( jobv, 'v' ) ) {
150  LAPACKE_free( v_t );
151  }
152 exit_level_3:
153  if( LAPACKE_lsame( jobu, 'u' ) ) {
154  LAPACKE_free( u_t );
155  }
156 exit_level_2:
157  LAPACKE_free( b_t );
158 exit_level_1:
159  LAPACKE_free( a_t );
160 exit_level_0:
161  if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
162  LAPACKE_xerbla( "LAPACKE_dggsvd_work", info );
163  }
164  } else {
165  info = -1;
166  LAPACKE_xerbla( "LAPACKE_dggsvd_work", info );
167  }
168  return info;
169 }
#define lapack_int
Definition: lapack.h:83
#define LAPACK_dggsvd(...)
Definition: lapack.h:5332
#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: