LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
lapacke_ctgsyl_work.c
Go to the documentation of this file.
1 /*****************************************************************************
2  Copyright (c) 2014, Intel Corp.
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without
6  modification, are permitted provided that the following conditions are met:
7 
8  * Redistributions of source code must retain the above copyright notice,
9  this list of conditions and the following disclaimer.
10  * Redistributions in binary form must reproduce the above copyright
11  notice, this list of conditions and the following disclaimer in the
12  documentation and/or other materials provided with the distribution.
13  * Neither the name of Intel Corporation nor the names of its contributors
14  may be used to endorse or promote products derived from this software
15  without specific prior written permission.
16 
17  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27  THE POSSIBILITY OF SUCH DAMAGE.
28 *****************************************************************************
29 * Contents: Native middle-level C interface to LAPACK function ctgsyl
30 * Author: Intel Corporation
31 * Generated November 2015
32 *****************************************************************************/
33 
34 #include "lapacke_utils.h"
35 
36 lapack_int LAPACKE_ctgsyl_work( int matrix_layout, char trans, lapack_int ijob,
38  const lapack_complex_float* a, lapack_int lda,
39  const lapack_complex_float* b, lapack_int ldb,
41  const lapack_complex_float* d, lapack_int ldd,
44  float* scale, float* dif,
45  lapack_complex_float* work, lapack_int lwork,
46  lapack_int* iwork )
47 {
48  lapack_int info = 0;
49  if( matrix_layout == LAPACK_COL_MAJOR ) {
50  /* Call LAPACK function and adjust info */
51  LAPACK_ctgsyl( &trans, &ijob, &m, &n, a, &lda, b, &ldb, c, &ldc, d,
52  &ldd, e, &lde, f, &ldf, scale, dif, work, &lwork, iwork,
53  &info );
54  if( info < 0 ) {
55  info = info - 1;
56  }
57  } else if( matrix_layout == LAPACK_ROW_MAJOR ) {
58  lapack_int lda_t = MAX(1,m);
59  lapack_int ldb_t = MAX(1,n);
60  lapack_int ldc_t = MAX(1,m);
61  lapack_int ldd_t = MAX(1,m);
62  lapack_int lde_t = MAX(1,n);
63  lapack_int ldf_t = MAX(1,m);
64  lapack_complex_float* a_t = NULL;
65  lapack_complex_float* b_t = NULL;
66  lapack_complex_float* c_t = NULL;
67  lapack_complex_float* d_t = NULL;
68  lapack_complex_float* e_t = NULL;
69  lapack_complex_float* f_t = NULL;
70  /* Check leading dimension(s) */
71  if( lda < m ) {
72  info = -7;
73  LAPACKE_xerbla( "LAPACKE_ctgsyl_work", info );
74  return info;
75  }
76  if( ldb < n ) {
77  info = -9;
78  LAPACKE_xerbla( "LAPACKE_ctgsyl_work", info );
79  return info;
80  }
81  if( ldc < n ) {
82  info = -11;
83  LAPACKE_xerbla( "LAPACKE_ctgsyl_work", info );
84  return info;
85  }
86  if( ldd < m ) {
87  info = -13;
88  LAPACKE_xerbla( "LAPACKE_ctgsyl_work", info );
89  return info;
90  }
91  if( lde < n ) {
92  info = -15;
93  LAPACKE_xerbla( "LAPACKE_ctgsyl_work", info );
94  return info;
95  }
96  if( ldf < n ) {
97  info = -17;
98  LAPACKE_xerbla( "LAPACKE_ctgsyl_work", info );
99  return info;
100  }
101  /* Query optimal working array(s) size if requested */
102  if( lwork == -1 ) {
103  LAPACK_ctgsyl( &trans, &ijob, &m, &n, a, &lda_t, b, &ldb_t, c,
104  &ldc_t, d, &ldd_t, e, &lde_t, f, &ldf_t, scale, dif,
105  work, &lwork, iwork, &info );
106  return (info < 0) ? (info - 1) : info;
107  }
108  /* Allocate memory for temporary array(s) */
109  a_t = (lapack_complex_float*)
110  LAPACKE_malloc( sizeof(lapack_complex_float) * lda_t * MAX(1,m) );
111  if( a_t == NULL ) {
113  goto exit_level_0;
114  }
115  b_t = (lapack_complex_float*)
116  LAPACKE_malloc( sizeof(lapack_complex_float) * ldb_t * MAX(1,n) );
117  if( b_t == NULL ) {
119  goto exit_level_1;
120  }
121  c_t = (lapack_complex_float*)
122  LAPACKE_malloc( sizeof(lapack_complex_float) * ldc_t * MAX(1,n) );
123  if( c_t == NULL ) {
125  goto exit_level_2;
126  }
127  d_t = (lapack_complex_float*)
128  LAPACKE_malloc( sizeof(lapack_complex_float) * ldd_t * MAX(1,m) );
129  if( d_t == NULL ) {
131  goto exit_level_3;
132  }
133  e_t = (lapack_complex_float*)
134  LAPACKE_malloc( sizeof(lapack_complex_float) * lde_t * MAX(1,n) );
135  if( e_t == NULL ) {
137  goto exit_level_4;
138  }
139  f_t = (lapack_complex_float*)
140  LAPACKE_malloc( sizeof(lapack_complex_float) * ldf_t * MAX(1,n) );
141  if( f_t == NULL ) {
143  goto exit_level_5;
144  }
145  /* Transpose input matrices */
146  LAPACKE_cge_trans( matrix_layout, m, m, a, lda, a_t, lda_t );
147  LAPACKE_cge_trans( matrix_layout, n, n, b, ldb, b_t, ldb_t );
148  LAPACKE_cge_trans( matrix_layout, m, n, c, ldc, c_t, ldc_t );
149  LAPACKE_cge_trans( matrix_layout, m, m, d, ldd, d_t, ldd_t );
150  LAPACKE_cge_trans( matrix_layout, n, n, e, lde, e_t, lde_t );
151  LAPACKE_cge_trans( matrix_layout, m, n, f, ldf, f_t, ldf_t );
152  /* Call LAPACK function and adjust info */
153  LAPACK_ctgsyl( &trans, &ijob, &m, &n, a_t, &lda_t, b_t, &ldb_t, c_t,
154  &ldc_t, d_t, &ldd_t, e_t, &lde_t, f_t, &ldf_t, scale,
155  dif, work, &lwork, iwork, &info );
156  if( info < 0 ) {
157  info = info - 1;
158  }
159  /* Transpose output matrices */
160  LAPACKE_cge_trans( LAPACK_COL_MAJOR, m, n, c_t, ldc_t, c, ldc );
161  LAPACKE_cge_trans( LAPACK_COL_MAJOR, m, n, f_t, ldf_t, f, ldf );
162  /* Release memory and exit */
163  LAPACKE_free( f_t );
164 exit_level_5:
165  LAPACKE_free( e_t );
166 exit_level_4:
167  LAPACKE_free( d_t );
168 exit_level_3:
169  LAPACKE_free( c_t );
170 exit_level_2:
171  LAPACKE_free( b_t );
172 exit_level_1:
173  LAPACKE_free( a_t );
174 exit_level_0:
175  if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
176  LAPACKE_xerbla( "LAPACKE_ctgsyl_work", info );
177  }
178  } else {
179  info = -1;
180  LAPACKE_xerbla( "LAPACKE_ctgsyl_work", info );
181  }
182  return info;
183 }
void LAPACKE_cge_trans(int matrix_layout, lapack_int m, lapack_int n, const lapack_complex_float *in, lapack_int ldin, lapack_complex_float *out, lapack_int ldout)
#define LAPACK_ROW_MAJOR
Definition: lapacke.h:119
#define lapack_complex_float
Definition: lapacke.h:74
logical function lde(RI, RJ, LR)
Definition: dblat2.f:2945
#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
lapack_int LAPACKE_ctgsyl_work(int matrix_layout, char trans, lapack_int ijob, lapack_int m, lapack_int n, const lapack_complex_float *a, lapack_int lda, const lapack_complex_float *b, lapack_int ldb, lapack_complex_float *c, lapack_int ldc, const lapack_complex_float *d, lapack_int ldd, const lapack_complex_float *e, lapack_int lde, lapack_complex_float *f, lapack_int ldf, float *scale, float *dif, lapack_complex_float *work, lapack_int lwork, lapack_int *iwork)
#define LAPACK_COL_MAJOR
Definition: lapacke.h:120
void LAPACKE_xerbla(const char *name, lapack_int info)
#define lapack_int
Definition: lapacke.h:47
#define LAPACK_TRANSPOSE_MEMORY_ERROR
Definition: lapacke.h:123
void LAPACK_ctgsyl(char *trans, lapack_int *ijob, lapack_int *m, lapack_int *n, const lapack_complex_float *a, lapack_int *lda, const lapack_complex_float *b, lapack_int *ldb, lapack_complex_float *c, lapack_int *ldc, const lapack_complex_float *d, lapack_int *ldd, const lapack_complex_float *e, lapack_int *lde, lapack_complex_float *f, lapack_int *ldf, float *scale, float *dif, lapack_complex_float *work, lapack_int *lwork, lapack_int *iwork, lapack_int *info)