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