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_GGEVX_TCC
34 #define CXXLAPACK_INTERFACE_GGEVX_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
ggevx(char balanc,char jobVL,char jobvr,char sense,IndexType n,float * A,IndexType ldA,float * B,IndexType ldB,float * alphar,float * alphai,float * beta,float * VL,IndexType ldVL,float * VR,IndexType ldVR,IndexType & ilo,IndexType & ihi,float * lscale,float * rscale,float & abnrm,float & bbnrm,float * rConde,float * rCondv,float * work,IndexType lWork,IndexType * iWork,bool * bwork)44 ggevx(char balanc,
45 char jobVL,
46 char jobvr,
47 char sense,
48 IndexType n,
49 float *A,
50 IndexType ldA,
51 float *B,
52 IndexType ldB,
53 float *alphar,
54 float *alphai,
55 float *beta,
56 float *VL,
57 IndexType ldVL,
58 float *VR,
59 IndexType ldVR,
60 IndexType &ilo,
61 IndexType &ihi,
62 float *lscale,
63 float *rscale,
64 float &abnrm,
65 float &bbnrm,
66 float *rConde,
67 float *rCondv,
68 float *work,
69 IndexType lWork,
70 IndexType *iWork,
71 bool *bwork)
72 {
73 CXXLAPACK_DEBUG_OUT("sggevx");
74
75 IndexType info;
76 // TODO: Convert bwork into a logical array!
77 LAPACK_IMPL(sggevx)(&balanc,
78 &jobVL,
79 &jobvr,
80 &sense,
81 &n,
82 A,
83 &ldA,
84 B,
85 &ldB,
86 alphar,
87 alphai,
88 beta,
89 VL,
90 &ldVL,
91 VR,
92 &ldVR,
93 &ilo,
94 &ihi,
95 lscale,
96 rscale,
97 &abnrm,
98 &bbnrm,
99 rConde,
100 rCondv,
101 work,
102 &lWork,
103 iWork,
104 bwork,
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
ggevx(char balanc,char jobVL,char jobvr,char sense,IndexType n,double * A,IndexType ldA,double * B,IndexType ldB,double * alphar,double * alphai,double * beta,double * VL,IndexType ldVL,double * VR,IndexType ldVR,IndexType & ilo,IndexType & ihi,double * lscale,double * rscale,double & abnrm,double & bbnrm,double * rConde,double * rCondv,double * work,IndexType lWork,IndexType * iWork,bool * bwork)117 ggevx(char balanc,
118 char jobVL,
119 char jobvr,
120 char sense,
121 IndexType n,
122 double *A,
123 IndexType ldA,
124 double *B,
125 IndexType ldB,
126 double *alphar,
127 double *alphai,
128 double *beta,
129 double *VL,
130 IndexType ldVL,
131 double *VR,
132 IndexType ldVR,
133 IndexType &ilo,
134 IndexType &ihi,
135 double *lscale,
136 double *rscale,
137 double &abnrm,
138 double &bbnrm,
139 double *rConde,
140 double *rCondv,
141 double *work,
142 IndexType lWork,
143 IndexType *iWork,
144 bool *bwork)
145 {
146 CXXLAPACK_DEBUG_OUT("dggevx");
147
148 IndexType info;
149 // TODO: Convert bwork into a logical array!
150 LAPACK_IMPL(dggevx)(&balanc,
151 &jobVL,
152 &jobvr,
153 &sense,
154 &n,
155 A,
156 &ldA,
157 B,
158 &ldB,
159 alphar,
160 alphai,
161 beta,
162 VL,
163 &ldVL,
164 VR,
165 &ldVR,
166 &ilo,
167 &ihi,
168 lscale,
169 rscale,
170 &abnrm,
171 &bbnrm,
172 rConde,
173 rCondv,
174 work,
175 &lWork,
176 iWork,
177 bwork,
178 &info);
179 # ifndef NDEBUG
180 if (info<0) {
181 std::cerr << "info = " << info << std::endl;
182 }
183 # endif
184 ASSERT(info>=0);
185 return info;
186 }
187
188 template <typename IndexType>
189 IndexType
ggevx(char balanc,char jobVL,char jobvr,char sense,IndexType n,std::complex<float> * A,IndexType ldA,std::complex<float> * B,IndexType ldB,std::complex<float> * alpha,std::complex<float> * beta,std::complex<float> * VL,IndexType ldVL,std::complex<float> * VR,IndexType ldVR,IndexType & ilo,IndexType & ihi,float * lscale,float * rscale,float & abnrm,float & bbnrm,float * rConde,float * rCondv,std::complex<float> * work,IndexType lWork,float * rWork,IndexType * iWork,bool * bwork)190 ggevx(char balanc,
191 char jobVL,
192 char jobvr,
193 char sense,
194 IndexType n,
195 std::complex<float > *A,
196 IndexType ldA,
197 std::complex<float > *B,
198 IndexType ldB,
199 std::complex<float > *alpha,
200 std::complex<float > *beta,
201 std::complex<float > *VL,
202 IndexType ldVL,
203 std::complex<float > *VR,
204 IndexType ldVR,
205 IndexType &ilo,
206 IndexType &ihi,
207 float *lscale,
208 float *rscale,
209 float &abnrm,
210 float &bbnrm,
211 float *rConde,
212 float *rCondv,
213 std::complex<float > *work,
214 IndexType lWork,
215 float *rWork,
216 IndexType *iWork,
217 bool *bwork)
218 {
219 CXXLAPACK_DEBUG_OUT("cggevx");
220
221 IndexType info;
222 // TODO: Convert bwork into a logical array!
223 LAPACK_IMPL(cggevx)(&balanc,
224 &jobVL,
225 &jobvr,
226 &sense,
227 &n,
228 reinterpret_cast<float *>(A),
229 &ldA,
230 reinterpret_cast<float *>(B),
231 &ldB,
232 reinterpret_cast<float *>(alpha),
233 reinterpret_cast<float *>(beta),
234 reinterpret_cast<float *>(VL),
235 &ldVL,
236 reinterpret_cast<float *>(VR),
237 &ldVR,
238 &ilo,
239 &ihi,
240 lscale,
241 rscale,
242 &abnrm,
243 &bbnrm,
244 rConde,
245 rCondv,
246 reinterpret_cast<float *>(work),
247 &lWork,
248 rWork,
249 iWork,
250 bwork,
251 &info);
252 # ifndef NDEBUG
253 if (info<0) {
254 std::cerr << "info = " << info << std::endl;
255 }
256 # endif
257 ASSERT(info>=0);
258 return info;
259 }
260
261 template <typename IndexType>
262 IndexType
ggevx(char balanc,char jobVL,char jobvr,char sense,IndexType n,std::complex<double> * A,IndexType ldA,std::complex<double> * B,IndexType ldB,std::complex<double> * alpha,std::complex<double> * beta,std::complex<double> * VL,IndexType ldVL,std::complex<double> * VR,IndexType ldVR,IndexType & ilo,IndexType & ihi,double * lscale,double * rscale,double & abnrm,double & bbnrm,double * rConde,double * rCondv,std::complex<double> * work,IndexType lWork,double * rWork,IndexType * iWork,bool * bwork)263 ggevx(char balanc,
264 char jobVL,
265 char jobvr,
266 char sense,
267 IndexType n,
268 std::complex<double> *A,
269 IndexType ldA,
270 std::complex<double> *B,
271 IndexType ldB,
272 std::complex<double> *alpha,
273 std::complex<double> *beta,
274 std::complex<double> *VL,
275 IndexType ldVL,
276 std::complex<double> *VR,
277 IndexType ldVR,
278 IndexType &ilo,
279 IndexType &ihi,
280 double *lscale,
281 double *rscale,
282 double &abnrm,
283 double &bbnrm,
284 double *rConde,
285 double *rCondv,
286 std::complex<double> *work,
287 IndexType lWork,
288 double *rWork,
289 IndexType *iWork,
290 bool *bwork)
291 {
292
293 CXXLAPACK_DEBUG_OUT("zggevx");
294
295 IndexType info;
296 // TODO: Convert bwork into a logical array!
297 LAPACK_IMPL(zggevx)(&balanc,
298 &jobVL,
299 &jobvr,
300 &sense,
301 &n,
302 reinterpret_cast<double *>(A),
303 &ldA,
304 reinterpret_cast<double *>(B),
305 &ldB,
306 reinterpret_cast<double *>(alpha),
307 reinterpret_cast<double *>(beta),
308 reinterpret_cast<double *>(VL),
309 &ldVL,
310 reinterpret_cast<double *>(VR),
311 &ldVR,
312 &ilo,
313 &ihi,
314 lscale,
315 rscale,
316 &abnrm,
317 &bbnrm,
318 rConde,
319 rCondv,
320 reinterpret_cast<double *>(work),
321 &lWork,
322 rWork,
323 iWork,
324 bwork,
325 &info);
326 # ifndef NDEBUG
327 if (info<0) {
328 std::cerr << "info = " << info << std::endl;
329 }
330 # endif
331 ASSERT(info>=0);
332 return info;
333 }
334
335
336 } // namespace cxxlapack
337
338 #endif // CXXLAPACK_INTERFACE_GGEVX_TCC
339