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