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_SYSV_TCC
34 #define CXXLAPACK_INTERFACE_SYSV_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
sysv(char uplo,IndexType n,IndexType nRhs,float * A,IndexType ldA,IndexType * iPiv,float * B,IndexType ldB,float * work,IndexType lWork)44 sysv (char uplo,
45 IndexType n,
46 IndexType nRhs,
47 float *A,
48 IndexType ldA,
49 IndexType *iPiv,
50 float *B,
51 IndexType ldB,
52 float *work,
53 IndexType lWork)
54 {
55 CXXLAPACK_DEBUG_OUT("ssysv");
56
57 IndexType info;
58 LAPACK_IMPL(ssysv) (&uplo,
59 &n,
60 &nRhs,
61 A,
62 &ldA,
63 iPiv,
64 B,
65 &ldB,
66 work,
67 &lWork,
68 &info);
69 # ifndef NDEBUG
70 if (info<0) {
71 std::cerr << "info = " << info << std::endl;
72 }
73 # endif
74 ASSERT(info>=0);
75 return info;
76 }
77
78
79 template <typename IndexType>
80 IndexType
sysv(char uplo,IndexType n,IndexType nRhs,double * A,IndexType ldA,IndexType * iPiv,double * B,IndexType ldB,double * work,IndexType lWork)81 sysv (char uplo,
82 IndexType n,
83 IndexType nRhs,
84 double *A,
85 IndexType ldA,
86 IndexType *iPiv,
87 double *B,
88 IndexType ldB,
89 double *work,
90 IndexType lWork)
91 {
92 CXXLAPACK_DEBUG_OUT("dsysv");
93
94 IndexType info;
95 LAPACK_IMPL(dsysv) (&uplo,
96 &n,
97 &nRhs,
98 A,
99 &ldA,
100 iPiv,
101 B,
102 &ldB,
103 work,
104 &lWork,
105 &info);
106 # ifndef NDEBUG
107 if (info<0) {
108 std::cerr << "info = " << info << std::endl;
109 }
110 # endif
111 ASSERT(info>=0);
112 return info;
113 }
114
115 template <typename IndexType>
116 IndexType
sysv(char uplo,IndexType n,IndexType nRhs,std::complex<float> * A,IndexType ldA,IndexType * iPiv,std::complex<float> * B,IndexType ldB,std::complex<float> * work,IndexType lWork)117 sysv (char uplo,
118 IndexType n,
119 IndexType nRhs,
120 std::complex<float > *A,
121 IndexType ldA,
122 IndexType *iPiv,
123 std::complex<float > *B,
124 IndexType ldB,
125 std::complex<float > *work,
126 IndexType lWork)
127 {
128 CXXLAPACK_DEBUG_OUT("csysv");
129
130 IndexType info;
131 LAPACK_IMPL(csysv) (&uplo,
132 &n,
133 &nRhs,
134 reinterpret_cast<float *>(A),
135 &ldA,
136 iPiv,
137 reinterpret_cast<float *>(B),
138 &ldB,
139 reinterpret_cast<float *>(work),
140 &lWork,
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
sysv(char uplo,IndexType n,IndexType nRhs,std::complex<double> * A,IndexType ldA,IndexType * iPiv,std::complex<double> * B,IndexType ldB,std::complex<double> * work,IndexType lWork)153 sysv (char uplo,
154 IndexType n,
155 IndexType nRhs,
156 std::complex<double> *A,
157 IndexType ldA,
158 IndexType *iPiv,
159 std::complex<double> *B,
160 IndexType ldB,
161 std::complex<double> *work,
162 IndexType lWork)
163 {
164 CXXLAPACK_DEBUG_OUT("zsysv");
165
166 IndexType info;
167 LAPACK_IMPL(zsysv) (&uplo,
168 &n,
169 &nRhs,
170 reinterpret_cast<double *>(A),
171 &ldA,
172 iPiv,
173 reinterpret_cast<double *>(B),
174 &ldB,
175 reinterpret_cast<double *>(work),
176 &lWork,
177 &info);
178 # ifndef NDEBUG
179 if (info<0) {
180 std::cerr << "info = " << info << std::endl;
181 }
182 # endif
183 ASSERT(info>=0);
184 return info;
185 }
186
187 } // namespace cxxlapack
188
189 #endif // CXXLAPACK_INTERFACE_SYSV_TCC
190