LAPACK  3.10.0
LAPACK: Linear Algebra PACKage

◆ LAPACKE_sgghd3_work()

lapack_int LAPACKE_sgghd3_work ( int  matrix_layout,
char  compq,
char  compz,
lapack_int  n,
lapack_int  ilo,
lapack_int  ihi,
float *  a,
lapack_int  lda,
float *  b,
lapack_int  ldb,
float *  q,
lapack_int  ldq,
float *  z,
lapack_int  ldz,
float *  work,
lapack_int  lwork 
)

Definition at line 35 of file lapacke_sgghd3_work.c.

41 {
42  lapack_int info = 0;
43  if( matrix_layout == LAPACK_COL_MAJOR ) {
44  /* Call LAPACK function and adjust info */
45  LAPACK_sgghd3( &compq, &compz, &n, &ilo, &ihi, a, &lda, b, &ldb, q,
46  &ldq, z, &ldz, work, &lwork, &info );
47  if( info < 0 ) {
48  info = info - 1;
49  }
50  } else if( matrix_layout == LAPACK_ROW_MAJOR ) {
51  lapack_int lda_t = MAX(1,n);
52  lapack_int ldb_t = MAX(1,n);
53  lapack_int ldq_t = MAX(1,n);
54  lapack_int ldz_t = MAX(1,n);
55  float* a_t = NULL;
56  float* b_t = NULL;
57  float* q_t = NULL;
58  float* z_t = NULL;
59  /* Query optimal working array(s) size if requested */
60  if( lwork == -1 ) {
61  LAPACK_sgghd3( &compq, &compz, &n, &ilo, &ihi, a, &lda, b, &ldb, q,
62  &ldq, z, &ldz, work, &lwork, &info );
63  return (info < 0) ? (info - 1) : info;
64  }
65  /* Check leading dimension(s) */
66  if( lda < n ) {
67  info = -8;
68  LAPACKE_xerbla( "LAPACKE_sgghd3_work", info );
69  return info;
70  }
71  if( ldb < n ) {
72  info = -10;
73  LAPACKE_xerbla( "LAPACKE_sgghd3_work", info );
74  return info;
75  }
76  if( ldq < n ) {
77  info = -12;
78  LAPACKE_xerbla( "LAPACKE_sgghd3_work", info );
79  return info;
80  }
81  if( ldz < n ) {
82  info = -14;
83  LAPACKE_xerbla( "LAPACKE_sgghd3_work", info );
84  return info;
85  }
86  /* Allocate memory for temporary array(s) */
87  a_t = (float*)LAPACKE_malloc( sizeof(float) * lda_t * MAX(1,n) );
88  if( a_t == NULL ) {
90  goto exit_level_0;
91  }
92  b_t = (float*)LAPACKE_malloc( sizeof(float) * ldb_t * MAX(1,n) );
93  if( b_t == NULL ) {
95  goto exit_level_1;
96  }
97  if( LAPACKE_lsame( compq, 'i' ) || LAPACKE_lsame( compq, 'v' ) ) {
98  q_t = (float*)LAPACKE_malloc( sizeof(float) * ldq_t * MAX(1,n) );
99  if( q_t == NULL ) {
101  goto exit_level_2;
102  }
103  }
104  if( LAPACKE_lsame( compz, 'i' ) || LAPACKE_lsame( compz, 'v' ) ) {
105  z_t = (float*)LAPACKE_malloc( sizeof(float) * ldz_t * MAX(1,n) );
106  if( z_t == NULL ) {
108  goto exit_level_3;
109  }
110  }
111  /* Transpose input matrices */
112  LAPACKE_sge_trans( matrix_layout, n, n, a, lda, a_t, lda_t );
113  LAPACKE_sge_trans( matrix_layout, n, n, b, ldb, b_t, ldb_t );
114  if( LAPACKE_lsame( compq, 'v' ) ) {
115  LAPACKE_sge_trans( matrix_layout, n, n, q, ldq, q_t, ldq_t );
116  }
117  if( LAPACKE_lsame( compz, 'v' ) ) {
118  LAPACKE_sge_trans( matrix_layout, n, n, z, ldz, z_t, ldz_t );
119  }
120  /* Call LAPACK function and adjust info */
121  LAPACK_sgghd3( &compq, &compz, &n, &ilo, &ihi, a_t, &lda_t, b_t, &ldb_t,
122  q_t, &ldq_t, z_t, &ldz_t, work, &lwork, &info );
123  if( info < 0 ) {
124  info = info - 1;
125  }
126  /* Transpose output matrices */
127  LAPACKE_sge_trans( LAPACK_COL_MAJOR, n, n, a_t, lda_t, a, lda );
128  LAPACKE_sge_trans( LAPACK_COL_MAJOR, n, n, b_t, ldb_t, b, ldb );
129  if( LAPACKE_lsame( compq, 'i' ) || LAPACKE_lsame( compq, 'v' ) ) {
130  LAPACKE_sge_trans( LAPACK_COL_MAJOR, n, n, q_t, ldq_t, q, ldq );
131  }
132  if( LAPACKE_lsame( compz, 'i' ) || LAPACKE_lsame( compz, 'v' ) ) {
133  LAPACKE_sge_trans( LAPACK_COL_MAJOR, n, n, z_t, ldz_t, z, ldz );
134  }
135  /* Release memory and exit */
136  if( LAPACKE_lsame( compz, 'i' ) || LAPACKE_lsame( compz, 'v' ) ) {
137  LAPACKE_free( z_t );
138  }
139  exit_level_3:
140  if( LAPACKE_lsame( compq, 'i' ) || LAPACKE_lsame( compq, 'v' ) ) {
141  LAPACKE_free( q_t );
142  }
143  exit_level_2:
144  LAPACKE_free( b_t );
145  exit_level_1:
146  LAPACKE_free( a_t );
147  exit_level_0:
148  if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
149  LAPACKE_xerbla( "LAPACKE_sgghd3_work", info );
150  }
151  } else {
152  info = -1;
153  LAPACKE_xerbla( "LAPACKE_sgghd3_work", info );
154  }
155  return info;
156 }
#define LAPACK_sgghd3(...)
Definition: lapack.h:5045
#define lapack_int
Definition: lapack.h:83
#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: