LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
lapacke_dtgsyl_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 dtgsyl
30 * Author: Intel Corporation
31 * Generated November 2015
32 *****************************************************************************/
33 
34 #include "lapacke_utils.h"
35 
36 lapack_int LAPACKE_dtgsyl_work( int matrix_layout, char trans, lapack_int ijob,
37  lapack_int m, lapack_int n, const double* a,
38  lapack_int lda, const double* b, lapack_int ldb,
39  double* c, lapack_int ldc, const double* d,
40  lapack_int ldd, const double* e, lapack_int lde,
41  double* f, lapack_int ldf, double* scale,
42  double* dif, double* work, lapack_int lwork,
43  lapack_int* iwork )
44 {
45  lapack_int info = 0;
46  if( matrix_layout == LAPACK_COL_MAJOR ) {
47  /* Call LAPACK function and adjust info */
48  LAPACK_dtgsyl( &trans, &ijob, &m, &n, a, &lda, b, &ldb, c, &ldc, d,
49  &ldd, e, &lde, f, &ldf, scale, dif, work, &lwork, iwork,
50  &info );
51  if( info < 0 ) {
52  info = info - 1;
53  }
54  } else if( matrix_layout == LAPACK_ROW_MAJOR ) {
55  lapack_int lda_t = MAX(1,m);
56  lapack_int ldb_t = MAX(1,n);
57  lapack_int ldc_t = MAX(1,m);
58  lapack_int ldd_t = MAX(1,m);
59  lapack_int lde_t = MAX(1,n);
60  lapack_int ldf_t = MAX(1,m);
61  double* a_t = NULL;
62  double* b_t = NULL;
63  double* c_t = NULL;
64  double* d_t = NULL;
65  double* e_t = NULL;
66  double* f_t = NULL;
67  /* Check leading dimension(s) */
68  if( lda < m ) {
69  info = -7;
70  LAPACKE_xerbla( "LAPACKE_dtgsyl_work", info );
71  return info;
72  }
73  if( ldb < n ) {
74  info = -9;
75  LAPACKE_xerbla( "LAPACKE_dtgsyl_work", info );
76  return info;
77  }
78  if( ldc < n ) {
79  info = -11;
80  LAPACKE_xerbla( "LAPACKE_dtgsyl_work", info );
81  return info;
82  }
83  if( ldd < m ) {
84  info = -13;
85  LAPACKE_xerbla( "LAPACKE_dtgsyl_work", info );
86  return info;
87  }
88  if( lde < n ) {
89  info = -15;
90  LAPACKE_xerbla( "LAPACKE_dtgsyl_work", info );
91  return info;
92  }
93  if( ldf < n ) {
94  info = -17;
95  LAPACKE_xerbla( "LAPACKE_dtgsyl_work", info );
96  return info;
97  }
98  /* Query optimal working array(s) size if requested */
99  if( lwork == -1 ) {
100  LAPACK_dtgsyl( &trans, &ijob, &m, &n, a, &lda_t, b, &ldb_t, c,
101  &ldc_t, d, &ldd_t, e, &lde_t, f, &ldf_t, scale, dif,
102  work, &lwork, iwork, &info );
103  return (info < 0) ? (info - 1) : info;
104  }
105  /* Allocate memory for temporary array(s) */
106  a_t = (double*)LAPACKE_malloc( sizeof(double) * lda_t * MAX(1,m) );
107  if( a_t == NULL ) {
109  goto exit_level_0;
110  }
111  b_t = (double*)LAPACKE_malloc( sizeof(double) * ldb_t * MAX(1,n) );
112  if( b_t == NULL ) {
114  goto exit_level_1;
115  }
116  c_t = (double*)LAPACKE_malloc( sizeof(double) * ldc_t * MAX(1,n) );
117  if( c_t == NULL ) {
119  goto exit_level_2;
120  }
121  d_t = (double*)LAPACKE_malloc( sizeof(double) * ldd_t * MAX(1,m) );
122  if( d_t == NULL ) {
124  goto exit_level_3;
125  }
126  e_t = (double*)LAPACKE_malloc( sizeof(double) * lde_t * MAX(1,n) );
127  if( e_t == NULL ) {
129  goto exit_level_4;
130  }
131  f_t = (double*)LAPACKE_malloc( sizeof(double) * ldf_t * MAX(1,n) );
132  if( f_t == NULL ) {
134  goto exit_level_5;
135  }
136  /* Transpose input matrices */
137  LAPACKE_dge_trans( matrix_layout, m, m, a, lda, a_t, lda_t );
138  LAPACKE_dge_trans( matrix_layout, n, n, b, ldb, b_t, ldb_t );
139  LAPACKE_dge_trans( matrix_layout, m, n, c, ldc, c_t, ldc_t );
140  LAPACKE_dge_trans( matrix_layout, m, m, d, ldd, d_t, ldd_t );
141  LAPACKE_dge_trans( matrix_layout, n, n, e, lde, e_t, lde_t );
142  LAPACKE_dge_trans( matrix_layout, m, n, f, ldf, f_t, ldf_t );
143  /* Call LAPACK function and adjust info */
144  LAPACK_dtgsyl( &trans, &ijob, &m, &n, a_t, &lda_t, b_t, &ldb_t, c_t,
145  &ldc_t, d_t, &ldd_t, e_t, &lde_t, f_t, &ldf_t, scale,
146  dif, work, &lwork, iwork, &info );
147  if( info < 0 ) {
148  info = info - 1;
149  }
150  /* Transpose output matrices */
151  LAPACKE_dge_trans( LAPACK_COL_MAJOR, m, n, c_t, ldc_t, c, ldc );
152  LAPACKE_dge_trans( LAPACK_COL_MAJOR, m, n, f_t, ldf_t, f, ldf );
153  /* Release memory and exit */
154  LAPACKE_free( f_t );
155 exit_level_5:
156  LAPACKE_free( e_t );
157 exit_level_4:
158  LAPACKE_free( d_t );
159 exit_level_3:
160  LAPACKE_free( c_t );
161 exit_level_2:
162  LAPACKE_free( b_t );
163 exit_level_1:
164  LAPACKE_free( a_t );
165 exit_level_0:
166  if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
167  LAPACKE_xerbla( "LAPACKE_dtgsyl_work", info );
168  }
169  } else {
170  info = -1;
171  LAPACKE_xerbla( "LAPACKE_dtgsyl_work", info );
172  }
173  return info;
174 }
void LAPACKE_dge_trans(int matrix_layout, lapack_int m, lapack_int n, const double *in, lapack_int ldin, double *out, lapack_int ldout)
#define LAPACK_ROW_MAJOR
Definition: lapacke.h:119
logical function lde(RI, RJ, LR)
Definition: dblat2.f:2945
void LAPACK_dtgsyl(char *trans, lapack_int *ijob, lapack_int *m, lapack_int *n, const double *a, lapack_int *lda, const double *b, lapack_int *ldb, double *c, lapack_int *ldc, const double *d, lapack_int *ldd, const double *e, lapack_int *lde, double *f, lapack_int *ldf, double *scale, double *dif, double *work, lapack_int *lwork, lapack_int *iwork, lapack_int *info)
lapack_int LAPACKE_dtgsyl_work(int matrix_layout, char trans, lapack_int ijob, lapack_int m, lapack_int n, const double *a, lapack_int lda, const double *b, lapack_int ldb, double *c, lapack_int ldc, const double *d, lapack_int ldd, const double *e, lapack_int lde, double *f, lapack_int ldf, double *scale, double *dif, double *work, lapack_int lwork, lapack_int *iwork)
#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
#define LAPACK_TRANSPOSE_MEMORY_ERROR
Definition: lapacke.h:123