OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
lapacke_zgbrfsx_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 zgbrfsx
30* Author: Intel Corporation
31*****************************************************************************/
32
33#include "lapacke_utils.h"
34
35lapack_int LAPACKE_zgbrfsx_work( int matrix_layout, char trans, char equed,
37 lapack_int nrhs,
38 const lapack_complex_double* ab,
39 lapack_int ldab,
40 const lapack_complex_double* afb,
41 lapack_int ldafb, const lapack_int* ipiv,
42 const double* r, const double* c,
45 double* rcond, double* berr,
46 lapack_int n_err_bnds, double* err_bnds_norm,
47 double* err_bnds_comp, lapack_int nparams,
48 double* params, lapack_complex_double* work,
49 double* rwork )
50{
51 lapack_int info = 0;
52 if( matrix_layout == LAPACK_COL_MAJOR ) {
53 /* Call LAPACK function and adjust info */
54 LAPACK_zgbrfsx( &trans, &equed, &n, &kl, &ku, &nrhs, ab, &ldab, afb,
55 &ldafb, ipiv, r, c, b, &ldb, x, &ldx, rcond, berr,
56 &n_err_bnds, err_bnds_norm, err_bnds_comp, &nparams,
57 params, work, rwork, &info );
58 if( info < 0 ) {
59 info = info - 1;
60 }
61 } else if( matrix_layout == LAPACK_ROW_MAJOR ) {
62 lapack_int ldab_t = MAX(1,kl+ku+1);
63 lapack_int ldafb_t = MAX(1,2*kl+ku+1);
64 lapack_int ldb_t = MAX(1,n);
65 lapack_int ldx_t = MAX(1,n);
66 lapack_complex_double* ab_t = NULL;
67 lapack_complex_double* afb_t = NULL;
68 lapack_complex_double* b_t = NULL;
69 lapack_complex_double* x_t = NULL;
70 double* err_bnds_norm_t = NULL;
71 double* err_bnds_comp_t = NULL;
72 /* Check leading dimension(s) */
73 if( ldab < n ) {
74 info = -9;
75 LAPACKE_xerbla( "LAPACKE_zgbrfsx_work", info );
76 return info;
77 }
78 if( ldafb < n ) {
79 info = -11;
80 LAPACKE_xerbla( "LAPACKE_zgbrfsx_work", info );
81 return info;
82 }
83 if( ldb < nrhs ) {
84 info = -16;
85 LAPACKE_xerbla( "LAPACKE_zgbrfsx_work", info );
86 return info;
87 }
88 if( ldx < nrhs ) {
89 info = -18;
90 LAPACKE_xerbla( "LAPACKE_zgbrfsx_work", info );
91 return info;
92 }
93 /* Allocate memory for temporary array(s) */
94 ab_t = (lapack_complex_double*)
95 LAPACKE_malloc( sizeof(lapack_complex_double) * ldab_t * MAX(1,n) );
96 if( ab_t == NULL ) {
98 goto exit_level_0;
99 }
100 afb_t = (lapack_complex_double*)
102 ldafb_t * MAX(1,n) );
103 if( afb_t == NULL ) {
105 goto exit_level_1;
106 }
107 b_t = (lapack_complex_double*)
109 ldb_t * MAX(1,nrhs) );
110 if( b_t == NULL ) {
112 goto exit_level_2;
113 }
114 x_t = (lapack_complex_double*)
116 ldx_t * MAX(1,nrhs) );
117 if( x_t == NULL ) {
119 goto exit_level_3;
120 }
121 err_bnds_norm_t = (double*)
122 LAPACKE_malloc( sizeof(double) * nrhs * MAX(1,n_err_bnds) );
123 if( err_bnds_norm_t == NULL ) {
125 goto exit_level_4;
126 }
127 err_bnds_comp_t = (double*)
128 LAPACKE_malloc( sizeof(double) * nrhs * MAX(1,n_err_bnds) );
129 if( err_bnds_comp_t == NULL ) {
131 goto exit_level_5;
132 }
133 /* Transpose input matrices */
134 LAPACKE_zgb_trans( matrix_layout, n, n, kl, ku, ab, ldab, ab_t, ldab_t );
135 LAPACKE_zgb_trans( matrix_layout, n, n, kl, kl+ku, afb, ldafb, afb_t,
136 ldafb_t );
137 LAPACKE_zge_trans( matrix_layout, n, nrhs, b, ldb, b_t, ldb_t );
138 LAPACKE_zge_trans( matrix_layout, n, nrhs, x, ldx, x_t, ldx_t );
139 /* Call LAPACK function and adjust info */
140 LAPACK_zgbrfsx( &trans, &equed, &n, &kl, &ku, &nrhs, ab_t, &ldab_t,
141 afb_t, &ldafb_t, ipiv, r, c, b_t, &ldb_t, x_t, &ldx_t,
142 rcond, berr, &n_err_bnds, err_bnds_norm_t,
143 err_bnds_comp_t, &nparams, params, work, rwork, &info );
144 if( info < 0 ) {
145 info = info - 1;
146 }
147 /* Transpose output matrices */
148 LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, nrhs, x_t, ldx_t, x, ldx );
149 LAPACKE_dge_trans( LAPACK_COL_MAJOR, nrhs, n_err_bnds, err_bnds_norm_t,
150 nrhs, err_bnds_norm, nrhs );
151 LAPACKE_dge_trans( LAPACK_COL_MAJOR, nrhs, n_err_bnds, err_bnds_comp_t,
152 nrhs, err_bnds_comp, nrhs );
153 /* Release memory and exit */
154 LAPACKE_free( err_bnds_comp_t );
155exit_level_5:
156 LAPACKE_free( err_bnds_norm_t );
157exit_level_4:
158 LAPACKE_free( x_t );
159exit_level_3:
160 LAPACKE_free( b_t );
161exit_level_2:
162 LAPACKE_free( afb_t );
163exit_level_1:
164 LAPACKE_free( ab_t );
165exit_level_0:
166 if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
167 LAPACKE_xerbla( "LAPACKE_zgbrfsx_work", info );
168 }
169 } else {
170 info = -1;
171 LAPACKE_xerbla( "LAPACKE_zgbrfsx_work", info );
172 }
173 return info;
174}
#define lapack_int
Definition lapack.h:83
#define LAPACK_zgbrfsx(...)
Definition lapack.h:919
#define lapack_complex_double
Definition lapack.h:63
#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
void LAPACKE_xerbla(const char *name, lapack_int info)
void LAPACKE_zge_trans(int matrix_layout, lapack_int m, lapack_int n, const lapack_complex_double *in, lapack_int ldin, lapack_complex_double *out, lapack_int ldout)
void LAPACKE_zgb_trans(int matrix_layout, lapack_int m, lapack_int n, lapack_int kl, lapack_int ku, const lapack_complex_double *in, lapack_int ldin, lapack_complex_double *out, lapack_int ldout)
#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)
lapack_int LAPACKE_zgbrfsx_work(int matrix_layout, char trans, char equed, lapack_int n, lapack_int kl, lapack_int ku, lapack_int nrhs, const lapack_complex_double *ab, lapack_int ldab, const lapack_complex_double *afb, lapack_int ldafb, const lapack_int *ipiv, const double *r, const double *c, const lapack_complex_double *b, lapack_int ldb, lapack_complex_double *x, lapack_int ldx, double *rcond, double *berr, lapack_int n_err_bnds, double *err_bnds_norm, double *err_bnds_comp, lapack_int nparams, double *params, lapack_complex_double *work, double *rwork)
n