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 high-level C interface to LAPACK function cgerfsx
30 * Author: Intel Corporation
31 * Generated November 2015
32 *****************************************************************************/
33 
34 #include "lapacke_utils.h"
35 
LAPACKE_cgerfsx(int matrix_layout,char trans,char equed,lapack_int n,lapack_int nrhs,const lapack_complex_float * a,lapack_int lda,const lapack_complex_float * af,lapack_int ldaf,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)36 lapack_int LAPACKE_cgerfsx( int matrix_layout, char trans, char equed,
37                             lapack_int n, lapack_int nrhs,
38                             const lapack_complex_float* a, lapack_int lda,
39                             const lapack_complex_float* af, lapack_int ldaf,
40                             const lapack_int* ipiv, const float* r,
41                             const float* c, const lapack_complex_float* b,
42                             lapack_int ldb, lapack_complex_float* x,
43                             lapack_int ldx, float* rcond, float* berr,
44                             lapack_int n_err_bnds, float* err_bnds_norm,
45                             float* err_bnds_comp, lapack_int nparams,
46                             float* params )
47 {
48     lapack_int info = 0;
49     float* rwork = NULL;
50     lapack_complex_float* work = NULL;
51     if( matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR ) {
52         LAPACKE_xerbla( "LAPACKE_cgerfsx", -1 );
53         return -1;
54     }
55 #ifndef LAPACK_DISABLE_NAN_CHECK
56     /* Optionally check input matrices for NaNs */
57     if( LAPACKE_cge_nancheck( matrix_layout, n, n, a, lda ) ) {
58         return -6;
59     }
60     if( LAPACKE_cge_nancheck( matrix_layout, n, n, af, ldaf ) ) {
61         return -8;
62     }
63     if( LAPACKE_cge_nancheck( matrix_layout, n, nrhs, b, ldb ) ) {
64         return -13;
65     }
66     if( LAPACKE_lsame( equed, 'b' ) || LAPACKE_lsame( equed, 'c' ) ) {
67         if( LAPACKE_s_nancheck( n, c, 1 ) ) {
68             return -12;
69         }
70     }
71     if( nparams>0 ) {
72         if( LAPACKE_s_nancheck( nparams, params, 1 ) ) {
73             return -23;
74         }
75     }
76     if( LAPACKE_lsame( equed, 'b' ) || LAPACKE_lsame( equed, 'r' ) ) {
77         if( LAPACKE_s_nancheck( n, r, 1 ) ) {
78             return -11;
79         }
80     }
81     if( LAPACKE_cge_nancheck( matrix_layout, n, nrhs, x, ldx ) ) {
82         return -15;
83     }
84 #endif
85     /* Allocate memory for working array(s) */
86     rwork = (float*)LAPACKE_malloc( sizeof(float) * MAX(1,3*n) );
87     if( rwork == NULL ) {
88         info = LAPACK_WORK_MEMORY_ERROR;
89         goto exit_level_0;
90     }
91     work = (lapack_complex_float*)
92         LAPACKE_malloc( sizeof(lapack_complex_float) * MAX(1,2*n) );
93     if( work == NULL ) {
94         info = LAPACK_WORK_MEMORY_ERROR;
95         goto exit_level_1;
96     }
97     /* Call middle-level interface */
98     info = LAPACKE_cgerfsx_work( matrix_layout, trans, equed, n, nrhs, a, lda,
99                                  af, ldaf, ipiv, r, c, b, ldb, x, ldx, rcond,
100                                  berr, n_err_bnds, err_bnds_norm, err_bnds_comp,
101                                  nparams, params, work, rwork );
102     /* Release memory and exit */
103     LAPACKE_free( work );
104 exit_level_1:
105     LAPACKE_free( rwork );
106 exit_level_0:
107     if( info == LAPACK_WORK_MEMORY_ERROR ) {
108         LAPACKE_xerbla( "LAPACKE_cgerfsx", info );
109     }
110     return info;
111 }
112