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_GTSV_TCC
34 #define CXXLAPACK_INTERFACE_GTSV_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
gtsv(IndexType n,IndexType nRhs,float * dl,float * d,float * du,float * B,IndexType ldB)44 gtsv(IndexType             n,
45      IndexType             nRhs,
46      float                 *dl,
47      float                 *d,
48      float                 *du,
49      float                 *B,
50      IndexType             ldB)
51 {
52     CXXLAPACK_DEBUG_OUT("sgtsv");
53 
54     IndexType info;
55     LAPACK_IMPL(sgtsv)(&n,
56                        &nRhs,
57                        dl,
58                        d,
59                        du,
60                        B,
61                        &ldB,
62                        &info);
63 #   ifndef NDEBUG
64     if (info<0) {
65         std::cerr << "info = " << info << std::endl;
66     }
67 #   endif
68     ASSERT(info>=0);
69     return info;
70 }
71 
72 template <typename IndexType>
73 IndexType
gtsv(IndexType n,IndexType nRhs,double * dl,double * d,double * du,double * B,IndexType ldB)74 gtsv(IndexType             n,
75      IndexType             nRhs,
76      double                *dl,
77      double                *d,
78      double                *du,
79      double                *B,
80      IndexType             ldB)
81 {
82     CXXLAPACK_DEBUG_OUT("dgtsv");
83 
84     IndexType info;
85     LAPACK_IMPL(dgtsv)(&n,
86                        &nRhs,
87                        dl,
88                        d,
89                        du,
90                        B,
91                        &ldB,
92                        &info);
93 #   ifndef NDEBUG
94     if (info<0) {
95         std::cerr << "info = " << info << std::endl;
96     }
97 #   endif
98     ASSERT(info>=0);
99     return info;
100 }
101 
102 template <typename IndexType>
103 IndexType
gtsv(IndexType n,IndexType nRhs,std::complex<float> * dl,std::complex<float> * d,std::complex<float> * du,std::complex<float> * B,IndexType ldB)104 gtsv(IndexType             n,
105      IndexType             nRhs,
106      std::complex<float >  *dl,
107      std::complex<float >  *d,
108      std::complex<float >  *du,
109      std::complex<float >  *B,
110      IndexType             ldB)
111 {
112     CXXLAPACK_DEBUG_OUT("cgtsv");
113 
114     IndexType info;
115     LAPACK_IMPL(cgtsv)(&n,
116                        &nRhs,
117                        reinterpret_cast<float  *>(dl),
118                        reinterpret_cast<float  *>(d),
119                        reinterpret_cast<float  *>(du),
120                        reinterpret_cast<float  *>(B),
121                        &ldB,
122                        &info);
123 #   ifndef NDEBUG
124     if (info<0) {
125         std::cerr << "info = " << info << std::endl;
126     }
127 #   endif
128     ASSERT(info>=0);
129     return info;
130 }
131 
132 template <typename IndexType>
133 IndexType
gtsv(IndexType n,IndexType nRhs,std::complex<double> * dl,std::complex<double> * d,std::complex<double> * du,std::complex<double> * B,IndexType ldB)134 gtsv(IndexType             n,
135      IndexType             nRhs,
136      std::complex<double>  *dl,
137      std::complex<double>  *d,
138      std::complex<double>  *du,
139      std::complex<double>  *B,
140      IndexType             ldB)
141 {
142     CXXLAPACK_DEBUG_OUT("zgtsv");
143 
144     IndexType info;
145     LAPACK_IMPL(zgtsv)(&n,
146                        &nRhs,
147                        reinterpret_cast<double *>(dl),
148                        reinterpret_cast<double *>(d),
149                        reinterpret_cast<double *>(du),
150                        reinterpret_cast<double *>(B),
151                        &ldB,
152                        &info);
153 #   ifndef NDEBUG
154     if (info<0) {
155         std::cerr << "info = " << info << std::endl;
156     }
157 #   endif
158     ASSERT(info>=0);
159     return info;
160 }
161 
162 } // namespace cxxlapack
163 
164 #endif // CXXLAPACK_INTERFACE_GTSV_TCC
165