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