LAPACK  3.10.0
LAPACK: Linear Algebra PACKage

◆ LAPACKE_sggsvp_work()

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

Definition at line 35 of file lapacke_sggsvp_work.c.

43 {
44  lapack_int info = 0;
45  if( matrix_layout == LAPACK_COL_MAJOR ) {
46  /* Call LAPACK function and adjust info */
47  LAPACK_sggsvp( &jobu, &jobv, &jobq, &m, &p, &n, a, &lda, b, &ldb, &tola,
48  &tolb, k, l, u, &ldu, v, &ldv, q, &ldq, iwork, tau, work,
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  float* a_t = NULL;
60  float* b_t = NULL;
61  float* u_t = NULL;
62  float* v_t = NULL;
63  float* q_t = NULL;
64  /* Check leading dimension(s) */
65  if( lda < n ) {
66  info = -9;
67  LAPACKE_xerbla( "LAPACKE_sggsvp_work", info );
68  return info;
69  }
70  if( ldb < n ) {
71  info = -11;
72  LAPACKE_xerbla( "LAPACKE_sggsvp_work", info );
73  return info;
74  }
75  if( ldq < n ) {
76  info = -21;
77  LAPACKE_xerbla( "LAPACKE_sggsvp_work", info );
78  return info;
79  }
80  if( ldu < m ) {
81  info = -17;
82  LAPACKE_xerbla( "LAPACKE_sggsvp_work", info );
83  return info;
84  }
85  if( ldv < m ) {
86  info = -19;
87  LAPACKE_xerbla( "LAPACKE_sggsvp_work", info );
88  return info;
89  }
90  /* Allocate memory for temporary array(s) */
91  a_t = (float*)LAPACKE_malloc( sizeof(float) * lda_t * MAX(1,n) );
92  if( a_t == NULL ) {
94  goto exit_level_0;
95  }
96  b_t = (float*)LAPACKE_malloc( sizeof(float) * 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 = (float*)LAPACKE_malloc( sizeof(float) * 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 = (float*)LAPACKE_malloc( sizeof(float) * ldv_t * MAX(1,m) );
110  if( v_t == NULL ) {
112  goto exit_level_3;
113  }
114  }
115  if( LAPACKE_lsame( jobq, 'q' ) ) {
116  q_t = (float*)LAPACKE_malloc( sizeof(float) * ldq_t * MAX(1,n) );
117  if( q_t == NULL ) {
119  goto exit_level_4;
120  }
121  }
122  /* Transpose input matrices */
123  LAPACKE_sge_trans( matrix_layout, m, n, a, lda, a_t, lda_t );
124  LAPACKE_sge_trans( matrix_layout, p, n, b, ldb, b_t, ldb_t );
125  /* Call LAPACK function and adjust info */
126  LAPACK_sggsvp( &jobu, &jobv, &jobq, &m, &p, &n, a_t, &lda_t, b_t,
127  &ldb_t, &tola, &tolb, k, l, u_t, &ldu_t, v_t, &ldv_t,
128  q_t, &ldq_t, iwork, tau, work, &info );
129  if( info < 0 ) {
130  info = info - 1;
131  }
132  /* Transpose output matrices */
133  LAPACKE_sge_trans( LAPACK_COL_MAJOR, m, n, a_t, lda_t, a, lda );
134  LAPACKE_sge_trans( LAPACK_COL_MAJOR, p, n, b_t, ldb_t, b, ldb );
135  if( LAPACKE_lsame( jobu, 'u' ) ) {
136  LAPACKE_sge_trans( LAPACK_COL_MAJOR, m, m, u_t, ldu_t, u, ldu );
137  }
138  if( LAPACKE_lsame( jobv, 'v' ) ) {
139  LAPACKE_sge_trans( LAPACK_COL_MAJOR, p, m, v_t, ldv_t, v, ldv );
140  }
141  if( LAPACKE_lsame( jobq, 'q' ) ) {
142  LAPACKE_sge_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_sggsvp_work", info );
163  }
164  } else {
165  info = -1;
166  LAPACKE_xerbla( "LAPACKE_sggsvp_work", info );
167  }
168  return info;
169 }
#define lapack_int
Definition: lapack.h:83
#define LAPACK_sggsvp(...)
Definition: lapack.h:5476
#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)
void LAPACKE_sge_trans(int matrix_layout, lapack_int m, lapack_int n, const float *in, lapack_int ldin, float *out, lapack_int ldout)
#define MAX(x, y)
Definition: lapacke_utils.h:46
Here is the call graph for this function:
Here is the caller graph for this function: