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_GBSV_TCC
34 #define CXXLAPACK_INTERFACE_GBSV_TCC 1
35 
36 #include <iostream>
37 #include <iostream>
38 #include "xflens/cxxlapack/interface/interface.h"
39 #include "xflens/cxxlapack/interface/interface.h"
40 #include "xflens/cxxlapack/netlib/netlib.h"
41 
42 namespace cxxlapack {
43 
44 template <typename IndexType>
45 IndexType
gbsv(IndexType n,IndexType kl,IndexType ku,IndexType nRhs,float * Ab,IndexType ldAb,IndexType * iPiv,float * B,IndexType ldB)46 gbsv(IndexType             n,
47      IndexType             kl,
48      IndexType             ku,
49      IndexType             nRhs,
50      float                 *Ab,
51      IndexType             ldAb,
52      IndexType             *iPiv,
53      float                 *B,
54      IndexType             ldB)
55 {
56     IndexType info;
57     CXXLAPACK_DEBUG_OUT("sgbsv");
58     LAPACK_IMPL(sgbsv)(&n,
59                        &kl,
60                        &ku,
61                        &nRhs,
62                        Ab,
63                        &ldAb,
64                        iPiv,
65                        B,
66                        &ldB,
67                        &info);
68 #   ifndef NDEBUG
69     if (info<0) {
70         std::cerr << "info = " << info << std::endl;
71     }
72 #   endif
73     ASSERT(info>=0);
74     return info;
75 }
76 
77 template <typename IndexType>
78 IndexType
gbsv(IndexType n,IndexType kl,IndexType ku,IndexType nRhs,double * Ab,IndexType ldAb,IndexType * iPiv,double * B,IndexType ldB)79 gbsv(IndexType             n,
80      IndexType             kl,
81      IndexType             ku,
82      IndexType             nRhs,
83      double                *Ab,
84      IndexType             ldAb,
85      IndexType             *iPiv,
86      double                *B,
87      IndexType             ldB)
88 {
89     IndexType info;
90     CXXLAPACK_DEBUG_OUT("dgbsv");
91     LAPACK_IMPL(dgbsv)(&n,
92                        &kl,
93                        &ku,
94                        &nRhs,
95                        Ab,
96                        &ldAb,
97                        iPiv,
98                        B,
99                        &ldB,
100                        &info);
101 #   ifndef NDEBUG
102     if (info<0) {
103         std::cerr << "info = " << info << std::endl;
104     }
105 #   endif
106     ASSERT(info>=0);
107     return info;
108 }
109 
110 template <typename IndexType>
111 IndexType
gbsv(IndexType n,IndexType kl,IndexType ku,IndexType nRhs,std::complex<float> * Ab,IndexType ldAb,IndexType * iPiv,std::complex<float> * B,IndexType ldB)112 gbsv(IndexType             n,
113      IndexType             kl,
114      IndexType             ku,
115      IndexType             nRhs,
116      std::complex<float >  *Ab,
117      IndexType             ldAb,
118      IndexType             *iPiv,
119      std::complex<float >  *B,
120      IndexType             ldB)
121 {
122     IndexType info;
123     CXXLAPACK_DEBUG_OUT("cgbsv");
124     LAPACK_IMPL(cgbsv)(&n,
125                        &kl,
126                        &ku,
127                        &nRhs,
128                        reinterpret_cast<float  *>(Ab),
129                        &ldAb,
130                        iPiv,
131                        reinterpret_cast<float  *>(B),
132                        &ldB,
133                        &info);
134 #   ifndef NDEBUG
135     if (info<0) {
136         std::cerr << "info = " << info << std::endl;
137     }
138 #   endif
139     ASSERT(info>=0);
140     return info;
141 }
142 
143 template <typename IndexType>
144 IndexType
gbsv(IndexType n,IndexType kl,IndexType ku,IndexType nRhs,std::complex<double> * Ab,IndexType ldAb,IndexType * iPiv,std::complex<double> * B,IndexType ldB)145 gbsv(IndexType             n,
146      IndexType             kl,
147      IndexType             ku,
148      IndexType             nRhs,
149      std::complex<double>  *Ab,
150      IndexType             ldAb,
151      IndexType             *iPiv,
152      std::complex<double>  *B,
153      IndexType             ldB)
154 {
155     IndexType info;
156     CXXLAPACK_DEBUG_OUT("zgbsv");
157     LAPACK_IMPL(zgbsv)(&n,
158                        &kl,
159                        &ku,
160                        &nRhs,
161                        reinterpret_cast<double *>(Ab),
162                        &ldAb,
163                        iPiv,
164                        reinterpret_cast<double *>(B),
165                        &ldB,
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 } // namespace cxxlapack
177 
178 #endif // CXXLAPACK_INTERFACE_GBSV_TCC
179