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_TPRFS_TCC
34 #define CXXLAPACK_INTERFACE_TPRFS_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
tprfs(char uplo,char trans,char diag,IndexType n,IndexType nRhs,const float * Ap,const float * B,IndexType ldB,const float * X,IndexType ldX,float * ferr,float * berr,float * work,IndexType * iWork)44 tprfs(char                  uplo,
45       char                  trans,
46       char                  diag,
47       IndexType             n,
48       IndexType             nRhs,
49       const float           *Ap,
50       const float           *B,
51       IndexType             ldB,
52       const float           *X,
53       IndexType             ldX,
54       float                 *ferr,
55       float                 *berr,
56       float                 *work,
57       IndexType             *iWork)
58 {
59     CXXLAPACK_DEBUG_OUT("stprfs");
60 
61     IndexType info;
62     LAPACK_IMPL(stprfs)(&uplo,
63                         &trans,
64                         &diag,
65                         &n,
66                         &nRhs,
67                         Ap,
68                         B,
69                         &ldB,
70                         X,
71                         &ldX,
72                         ferr,
73                         berr,
74                         work,
75                         iWork,
76                         &info);
77 #   ifndef NDEBUG
78     if (info<0) {
79         std::cerr << "info = " << info << std::endl;
80     }
81 #   endif
82     ASSERT(info>=0);
83     return info;
84 }
85 
86 
87 template <typename IndexType>
88 IndexType
tprfs(char uplo,char trans,char diag,IndexType n,IndexType nRhs,const double * Ap,const double * B,IndexType ldB,const double * X,IndexType ldX,double * ferr,double * berr,double * work,IndexType * iWork)89 tprfs(char                  uplo,
90       char                  trans,
91       char                  diag,
92       IndexType             n,
93       IndexType             nRhs,
94       const double          *Ap,
95       const double          *B,
96       IndexType             ldB,
97       const double          *X,
98       IndexType             ldX,
99       double                *ferr,
100       double                *berr,
101       double                *work,
102       IndexType             *iWork)
103 {
104     CXXLAPACK_DEBUG_OUT("dtprfs");
105 
106     IndexType info;
107     LAPACK_IMPL(dtprfs)(&uplo,
108                         &trans,
109                         &diag,
110                         &n,
111                         &nRhs,
112                         Ap,
113                         B,
114                         &ldB,
115                         X,
116                         &ldX,
117                         ferr,
118                         berr,
119                         work,
120                         iWork,
121                         &info);
122 #   ifndef NDEBUG
123     if (info<0) {
124         std::cerr << "info = " << info << std::endl;
125     }
126 #   endif
127     ASSERT(info>=0);
128     return info;
129 }
130 
131 
132 template <typename IndexType>
133 IndexType
tprfs(char uplo,char trans,char diag,IndexType n,IndexType nRhs,const std::complex<float> * Ap,const std::complex<float> * B,IndexType ldB,const std::complex<float> * X,IndexType ldX,float * ferr,float * berr,std::complex<float> * work,float * rWork)134 tprfs(char                        uplo,
135       char                        trans,
136       char                        diag,
137       IndexType                   n,
138       IndexType                   nRhs,
139       const std::complex<float >  *Ap,
140       const std::complex<float >  *B,
141       IndexType                   ldB,
142       const std::complex<float >  *X,
143       IndexType                   ldX,
144       float                       *ferr,
145       float                       *berr,
146       std::complex<float >        *work,
147       float                       *rWork)
148 {
149     CXXLAPACK_DEBUG_OUT("ctprfs");
150 
151     IndexType info;
152     LAPACK_IMPL(ctprfs)(&uplo,
153                         &trans,
154                         &diag,
155                         &n,
156                         &nRhs,
157                         reinterpret_cast<const float  *>(Ap),
158                         reinterpret_cast<const float  *>(B),
159                         &ldB,
160                         reinterpret_cast<const float  *>(X),
161                         &ldX,
162                         ferr,
163                         berr,
164                         reinterpret_cast<float  *>(work),
165                         rWork,
166                         &info);
167 #   ifndef NDEBUG
168     if (info<0) {
169         std::cerr << "info = " << info << std::endl;
170     }
171 #   endif
172     ASSERT(info>=0);
173     return info;
174 }
175 
176 template <typename IndexType>
177 IndexType
tprfs(char uplo,char trans,char diag,IndexType n,IndexType nRhs,const std::complex<double> * Ap,const std::complex<double> * B,IndexType ldB,const std::complex<double> * X,IndexType ldX,double * ferr,double * berr,std::complex<double> * work,double * rWork)178 tprfs(char                        uplo,
179       char                        trans,
180       char                        diag,
181       IndexType                   n,
182       IndexType                   nRhs,
183       const std::complex<double>  *Ap,
184       const std::complex<double>  *B,
185       IndexType                   ldB,
186       const std::complex<double>  *X,
187       IndexType                   ldX,
188       double                      *ferr,
189       double                      *berr,
190       std::complex<double>        *work,
191       double                      *rWork)
192 {
193     CXXLAPACK_DEBUG_OUT("ztprfs");
194 
195     IndexType info;
196     LAPACK_IMPL(ztprfs)(&uplo,
197                         &trans,
198                         &diag,
199                         &n,
200                         &nRhs,
201                         reinterpret_cast<const double *>(Ap),
202                         reinterpret_cast<const double *>(B),
203                         &ldB,
204                         reinterpret_cast<const double *>(X),
205                         &ldX,
206                         ferr,
207                         berr,
208                         reinterpret_cast<double *>(work),
209                         rWork,
210                         &info);
211 #   ifndef NDEBUG
212     if (info<0) {
213         std::cerr << "info = " << info << std::endl;
214     }
215 #   endif
216     ASSERT(info>=0);
217     return info;
218 }
219 
220 } // namespace cxxlapack
221 
222 #endif // CXXLAPACK_INTERFACE_TPRFS_TCC
223