1 /*
2  *   Copyright (c) 2012, Michael Lehn, Klaus Pototzky
3  *
4  *   All rights reserved.
5  *
6  *   Redistribution and use in source and binary forms, with or without
7  *   modification, are permitted provided that the following conditions
8  *   are met:
9  *
10  *   1) Redistributions of source code must retain the above copyright
11  *      notice, this list of conditions and the following disclaimer.
12  *   2) Redistributions in binary form must reproduce the above copyright
13  *      notice, this list of conditions and the following disclaimer in
14  *      the documentation and/or other materials provided with the
15  *      distribution.
16  *   3) Neither the name of the FLENS development group nor the names of
17  *      its contributors may be used to endorse or promote products derived
18  *      from this software without specific prior written permission.
19  *
20  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef CXXLAPACK_INTERFACE_POSVX_TCC
34 #define CXXLAPACK_INTERFACE_POSVX_TCC 1
35 
36 #include <iostream>
37 #include "xflens/cxxlapack/interface/interface.h"
38 #include "xflens/cxxlapack/netlib/netlib.h"
39 
40 namespace cxxlapack {
41 
42 template <typename IndexType>
43 IndexType
posvx(char fact,char uplo,IndexType n,IndexType nRhs,float * A,IndexType ldA,float * Af,IndexType ldAf,char & equed,float * s,float * B,IndexType ldB,float * X,IndexType ldX,float & rCond,float * ferr,float * berr,float * work,IndexType * iWork)44 posvx(char                  fact,
45       char                  uplo,
46       IndexType             n,
47       IndexType             nRhs,
48       float                 *A,
49       IndexType             ldA,
50       float                 *Af,
51       IndexType             ldAf,
52       char                  &equed,
53       float                 *s,
54       float                 *B,
55       IndexType             ldB,
56       float                 *X,
57       IndexType             ldX,
58       float                 &rCond,
59       float                 *ferr,
60       float                 *berr,
61       float                 *work,
62       IndexType             *iWork)
63 {
64     CXXLAPACK_DEBUG_OUT("sposvx");
65 
66     IndexType info;
67     LAPACK_IMPL(sposvx)(&fact,
68                         &uplo,
69                         &n,
70                         &nRhs,
71                         A,
72                         &ldA,
73                         Af,
74                         &ldAf,
75                         &equed,
76                         s,
77                         B,
78                         &ldB,
79                         X,
80                         &ldX,
81                         &rCond,
82                         ferr,
83                         berr,
84                         work,
85                         iWork,
86                         &info);
87 #   ifndef NDEBUG
88     if (info<0) {
89         std::cerr << "info = " << info << std::endl;
90     }
91 #   endif
92     ASSERT(info>=0);
93     return info;
94 }
95 
96 
97 template <typename IndexType>
98 IndexType
posvx(char fact,char uplo,IndexType n,IndexType nRhs,double * A,IndexType ldA,double * Af,IndexType ldAf,char & equed,double * s,double * B,IndexType ldB,double * X,IndexType ldX,double & rCond,double * ferr,double * berr,double * work,IndexType * iWork)99 posvx(char                  fact,
100       char                  uplo,
101       IndexType             n,
102       IndexType             nRhs,
103       double                *A,
104       IndexType             ldA,
105       double                *Af,
106       IndexType             ldAf,
107       char                  &equed,
108       double                *s,
109       double                *B,
110       IndexType             ldB,
111       double                *X,
112       IndexType             ldX,
113       double                &rCond,
114       double                *ferr,
115       double                *berr,
116       double                *work,
117       IndexType             *iWork)
118 {
119     CXXLAPACK_DEBUG_OUT("dposvx");
120 
121     IndexType info;
122     LAPACK_IMPL(dposvx)(&fact,
123                         &uplo,
124                         &n,
125                         &nRhs,
126                         A,
127                         &ldA,
128                         Af,
129                         &ldAf,
130                         &equed,
131                         s,
132                         B,
133                         &ldB,
134                         X,
135                         &ldX,
136                         &rCond,
137                         ferr,
138                         berr,
139                         work,
140                         iWork,
141                         &info);
142 #   ifndef NDEBUG
143     if (info<0) {
144         std::cerr << "info = " << info << std::endl;
145     }
146 #   endif
147     ASSERT(info>=0);
148     return info;
149 }
150 
151 template <typename IndexType>
152 IndexType
posvx(char fact,char uplo,IndexType n,IndexType nRhs,std::complex<float> * A,IndexType ldA,std::complex<float> * Af,IndexType ldAf,char & equed,float * s,std::complex<float> * B,IndexType ldB,std::complex<float> * X,IndexType ldX,float & rCond,float * ferr,float * berr,std::complex<float> * work,float * rWork)153 posvx(char                  fact,
154       char                  uplo,
155       IndexType             n,
156       IndexType             nRhs,
157       std::complex<float >  *A,
158       IndexType             ldA,
159       std::complex<float >  *Af,
160       IndexType             ldAf,
161       char                  &equed,
162       float                 *s,
163       std::complex<float >  *B,
164       IndexType             ldB,
165       std::complex<float >  *X,
166       IndexType             ldX,
167       float                 &rCond,
168       float                 *ferr,
169       float                 *berr,
170       std::complex<float >  *work,
171       float                 *rWork)
172 {
173     CXXLAPACK_DEBUG_OUT("cposvx");
174 
175     IndexType info;
176     LAPACK_IMPL(cposvx)(&fact,
177                         &uplo,
178                         &n,
179                         &nRhs,
180                         reinterpret_cast<float  *>(A),
181                         &ldA,
182                         reinterpret_cast<float  *>(Af),
183                         &ldAf,
184                         &equed,
185                         s,
186                         reinterpret_cast<float  *>(B),
187                         &ldB,
188                         reinterpret_cast<float  *>(X),
189                         &ldX,
190                         &rCond,
191                         ferr,
192                         berr,
193                         reinterpret_cast<float  *>(work),
194                         rWork,
195                         &info);
196 #   ifndef NDEBUG
197     if (info<0) {
198         std::cerr << "info = " << info << std::endl;
199     }
200 #   endif
201     ASSERT(info>=0);
202     return info;
203 }
204 
205 template <typename IndexType>
206 IndexType
posvx(char fact,char uplo,IndexType n,IndexType nRhs,std::complex<double> * A,IndexType ldA,std::complex<double> * Af,IndexType ldAf,char & equed,double * s,std::complex<double> * B,IndexType ldB,std::complex<double> * X,IndexType ldX,double & rCond,double * ferr,double * berr,std::complex<double> * work,double * rWork)207 posvx(char                  fact,
208       char                  uplo,
209       IndexType             n,
210       IndexType             nRhs,
211       std::complex<double>  *A,
212       IndexType             ldA,
213       std::complex<double>  *Af,
214       IndexType             ldAf,
215       char                  &equed,
216       double                *s,
217       std::complex<double>  *B,
218       IndexType             ldB,
219       std::complex<double>  *X,
220       IndexType             ldX,
221       double                &rCond,
222       double                *ferr,
223       double                *berr,
224       std::complex<double>  *work,
225       double                *rWork)
226 {
227     CXXLAPACK_DEBUG_OUT("zposvx");
228 
229     IndexType info;
230     LAPACK_IMPL(zposvx)(&fact,
231                         &uplo,
232                         &n,
233                         &nRhs,
234                         reinterpret_cast<double *>(A),
235                         &ldA,
236                         reinterpret_cast<double *>(Af),
237                         &ldAf,
238                         &equed,
239                         s,
240                         reinterpret_cast<double *>(B),
241                         &ldB,
242                         reinterpret_cast<double *>(X),
243                         &ldX,
244                         &rCond,
245                         ferr,
246                         berr,
247                         reinterpret_cast<double *>(work),
248                         rWork,
249                         &info);
250 #   ifndef NDEBUG
251     if (info<0) {
252         std::cerr << "info = " << info << std::endl;
253     }
254 #   endif
255     ASSERT(info>=0);
256     return info;
257 }
258 
259 } // namespace cxxlapack
260 
261 #endif // CXXLAPACK_INTERFACE_POSVX_TCC
262