LAPACK  3.10.1
LAPACK: Linear Algebra PACKage

◆ LAPACKE_zgetsls_work()

lapack_int LAPACKE_zgetsls_work ( int  matrix_layout,
char  trans,
lapack_int  m,
lapack_int  n,
lapack_int  nrhs,
lapack_complex_double a,
lapack_int  lda,
lapack_complex_double b,
lapack_int  ldb,
lapack_complex_double work,
lapack_int  lwork 
)

Definition at line 35 of file lapacke_zgetsls_work.c.

40 {
41  lapack_int info = 0;
42  if( matrix_layout == LAPACK_COL_MAJOR ) {
43  /* Call LAPACK function and adjust info */
44  LAPACK_zgetsls( &trans, &m, &n, &nrhs, a, &lda, b, &ldb, work, &lwork,
45  &info );
46  if( info < 0 ) {
47  info = info - 1;
48  }
49  } else if( matrix_layout == LAPACK_ROW_MAJOR ) {
50  lapack_int lda_t = MAX(1,m);
51  lapack_int ldb_t = MAX(1,MAX(m,n));
52  lapack_complex_double* a_t = NULL;
53  lapack_complex_double* b_t = NULL;
54  /* Check leading dimension(s) */
55  if( lda < n ) {
56  info = -7;
57  LAPACKE_xerbla( "LAPACKE_zgetsls_work", info );
58  return info;
59  }
60  if( ldb < nrhs ) {
61  info = -9;
62  LAPACKE_xerbla( "LAPACKE_zgetsls_work", info );
63  return info;
64  }
65  /* Query optimal working array(s) size if requested */
66  if( lwork == -1 ) {
67  LAPACK_zgetsls( &trans, &m, &n, &nrhs, a, &lda_t, b, &ldb_t, work,
68  &lwork, &info );
69  return (info < 0) ? (info - 1) : info;
70  }
71  /* Allocate memory for temporary array(s) */
72  a_t = (lapack_complex_double*)
73  LAPACKE_malloc( sizeof(lapack_complex_double) * lda_t * MAX(1,n) );
74  if( a_t == NULL ) {
76  goto exit_level_0;
77  }
78  b_t = (lapack_complex_double*)
80  ldb_t * MAX(1,nrhs) );
81  if( b_t == NULL ) {
83  goto exit_level_1;
84  }
85  /* Transpose input matrices */
86  LAPACKE_zge_trans( matrix_layout, m, n, a, lda, a_t, lda_t );
87  LAPACKE_zge_trans( matrix_layout, MAX(m,n), nrhs, b, ldb, b_t, ldb_t );
88  /* Call LAPACK function and adjust info */
89  LAPACK_zgetsls( &trans, &m, &n, &nrhs, a_t, &lda_t, b_t, &ldb_t, work,
90  &lwork, &info );
91  if( info < 0 ) {
92  info = info - 1;
93  }
94  /* Transpose output matrices */
95  LAPACKE_zge_trans( LAPACK_COL_MAJOR, m, n, a_t, lda_t, a, lda );
96  LAPACKE_zge_trans( LAPACK_COL_MAJOR, MAX(m,n), nrhs, b_t, ldb_t, b,
97  ldb );
98  /* Release memory and exit */
99  LAPACKE_free( b_t );
100 exit_level_1:
101  LAPACKE_free( a_t );
102 exit_level_0:
103  if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
104  LAPACKE_xerbla( "LAPACKE_zgetsls_work", info );
105  }
106  } else {
107  info = -1;
108  LAPACKE_xerbla( "LAPACKE_zgetsls_work", info );
109  }
110  return info;
111 }
#define lapack_int
Definition: lapack.h:83
#define LAPACK_zgetsls(...)
Definition: lapack.h:4161
#define lapack_complex_double
Definition: lapack.h:63
#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
void LAPACKE_xerbla(const char *name, lapack_int info)
void LAPACKE_zge_trans(int matrix_layout, lapack_int m, lapack_int n, const lapack_complex_double *in, lapack_int ldin, lapack_complex_double *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: