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