LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
lapack_int LAPACKE_stgsen_work ( int  matrix_layout,
lapack_int  ijob,
lapack_logical  wantq,
lapack_logical  wantz,
const lapack_logical select,
lapack_int  n,
float *  a,
lapack_int  lda,
float *  b,
lapack_int  ldb,
float *  alphar,
float *  alphai,
float *  beta,
float *  q,
lapack_int  ldq,
float *  z,
lapack_int  ldz,
lapack_int m,
float *  pl,
float *  pr,
float *  dif,
float *  work,
lapack_int  lwork,
lapack_int iwork,
lapack_int  liwork 
)

Definition at line 36 of file lapacke_stgsen_work.c.

46 {
47  lapack_int info = 0;
48  if( matrix_layout == LAPACK_COL_MAJOR ) {
49  /* Call LAPACK function and adjust info */
50  LAPACK_stgsen( &ijob, &wantq, &wantz, select, &n, a, &lda, b, &ldb,
51  alphar, alphai, beta, q, &ldq, z, &ldz, m, pl, pr, dif,
52  work, &lwork, iwork, &liwork, &info );
53  if( info < 0 ) {
54  info = info - 1;
55  }
56  } else if( matrix_layout == LAPACK_ROW_MAJOR ) {
57  lapack_int lda_t = MAX(1,n);
58  lapack_int ldb_t = MAX(1,n);
59  lapack_int ldq_t = MAX(1,n);
60  lapack_int ldz_t = MAX(1,n);
61  float* a_t = NULL;
62  float* b_t = NULL;
63  float* q_t = NULL;
64  float* z_t = NULL;
65  /* Check leading dimension(s) */
66  if( lda < n ) {
67  info = -8;
68  LAPACKE_xerbla( "LAPACKE_stgsen_work", info );
69  return info;
70  }
71  if( ldb < n ) {
72  info = -10;
73  LAPACKE_xerbla( "LAPACKE_stgsen_work", info );
74  return info;
75  }
76  if( ldq < n ) {
77  info = -15;
78  LAPACKE_xerbla( "LAPACKE_stgsen_work", info );
79  return info;
80  }
81  if( ldz < n ) {
82  info = -17;
83  LAPACKE_xerbla( "LAPACKE_stgsen_work", info );
84  return info;
85  }
86  /* Query optimal working array(s) size if requested */
87  if( liwork == -1 || lwork == -1 ) {
88  LAPACK_stgsen( &ijob, &wantq, &wantz, select, &n, a, &lda_t, b,
89  &ldb_t, alphar, alphai, beta, q, &ldq_t, z, &ldz_t,
90  m, pl, pr, dif, work, &lwork, iwork, &liwork,
91  &info );
92  return (info < 0) ? (info - 1) : info;
93  }
94  /* Allocate memory for temporary array(s) */
95  a_t = (float*)LAPACKE_malloc( sizeof(float) * lda_t * MAX(1,n) );
96  if( a_t == NULL ) {
98  goto exit_level_0;
99  }
100  b_t = (float*)LAPACKE_malloc( sizeof(float) * ldb_t * MAX(1,n) );
101  if( b_t == NULL ) {
103  goto exit_level_1;
104  }
105  if( wantq ) {
106  q_t = (float*)LAPACKE_malloc( sizeof(float) * ldq_t * MAX(1,n) );
107  if( q_t == NULL ) {
109  goto exit_level_2;
110  }
111  }
112  if( wantz ) {
113  z_t = (float*)LAPACKE_malloc( sizeof(float) * ldz_t * MAX(1,n) );
114  if( z_t == NULL ) {
116  goto exit_level_3;
117  }
118  }
119  /* Transpose input matrices */
120  LAPACKE_sge_trans( matrix_layout, n, n, a, lda, a_t, lda_t );
121  LAPACKE_sge_trans( matrix_layout, n, n, b, ldb, b_t, ldb_t );
122  if( wantq ) {
123  LAPACKE_sge_trans( matrix_layout, n, n, q, ldq, q_t, ldq_t );
124  }
125  if( wantz ) {
126  LAPACKE_sge_trans( matrix_layout, n, n, z, ldz, z_t, ldz_t );
127  }
128  /* Call LAPACK function and adjust info */
129  LAPACK_stgsen( &ijob, &wantq, &wantz, select, &n, a_t, &lda_t, b_t,
130  &ldb_t, alphar, alphai, beta, q_t, &ldq_t, z_t, &ldz_t,
131  m, pl, pr, dif, work, &lwork, iwork, &liwork, &info );
132  if( info < 0 ) {
133  info = info - 1;
134  }
135  /* Transpose output matrices */
136  LAPACKE_sge_trans( LAPACK_COL_MAJOR, n, n, a_t, lda_t, a, lda );
137  LAPACKE_sge_trans( LAPACK_COL_MAJOR, n, n, b_t, ldb_t, b, ldb );
138  if( wantq ) {
139  LAPACKE_sge_trans( LAPACK_COL_MAJOR, n, n, q_t, ldq_t, q, ldq );
140  }
141  if( wantz ) {
142  LAPACKE_sge_trans( LAPACK_COL_MAJOR, n, n, z_t, ldz_t, z, ldz );
143  }
144  /* Release memory and exit */
145  if( wantz ) {
146  LAPACKE_free( z_t );
147  }
148 exit_level_3:
149  if( wantq ) {
150  LAPACKE_free( q_t );
151  }
152 exit_level_2:
153  LAPACKE_free( b_t );
154 exit_level_1:
155  LAPACKE_free( a_t );
156 exit_level_0:
157  if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
158  LAPACKE_xerbla( "LAPACKE_stgsen_work", info );
159  }
160  } else {
161  info = -1;
162  LAPACKE_xerbla( "LAPACKE_stgsen_work", info );
163  }
164  return info;
165 }
#define LAPACK_ROW_MAJOR
Definition: lapacke.h:119
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:47
#define LAPACKE_free(p)
Definition: lapacke.h:113
#define LAPACKE_malloc(size)
Definition: lapacke.h:110
#define LAPACK_COL_MAJOR
Definition: lapacke.h:120
void LAPACKE_xerbla(const char *name, lapack_int info)
#define lapack_int
Definition: lapacke.h:47
void LAPACK_stgsen(lapack_int *ijob, lapack_logical *wantq, lapack_logical *wantz, const lapack_logical *select, lapack_int *n, float *a, lapack_int *lda, float *b, lapack_int *ldb, float *alphar, float *alphai, float *beta, float *q, lapack_int *ldq, float *z, lapack_int *ldz, lapack_int *m, float *pl, float *pr, float *dif, float *work, lapack_int *lwork, lapack_int *iwork, lapack_int *liwork, lapack_int *info)
#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: