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_GBEQU_TCC
34 #define CXXLAPACK_INTERFACE_GBEQU_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
gbequ(IndexType m,IndexType n,IndexType kl,IndexType ku,const float * Ab,IndexType ldAb,float * r,float * c,float & rowcnd,float & colcnd,float & amax)44 gbequ(IndexType             m,
45       IndexType             n,
46       IndexType             kl,
47       IndexType             ku,
48       const float           *Ab,
49       IndexType             ldAb,
50       float                 *r,
51       float                 *c,
52       float                 &rowcnd,
53       float                 &colcnd,
54       float                 &amax)
55 {
56     IndexType info;
57     CXXLAPACK_DEBUG_OUT("sgbequ");
58     LAPACK_IMPL(sgbequ)(&m,
59                         &n,
60                         &kl,
61                         &ku,
62                         Ab,
63                         &ldAb,
64                         r,
65                         c,
66                         &rowcnd,
67                         &colcnd,
68                         &amax,
69                         &info);
70 #   ifndef NDEBUG
71     if (info<0) {
72         std::cerr << "info = " << info << std::endl;
73     }
74 #   endif
75     ASSERT(info>=0);
76     return info;
77 }
78 
79 template <typename IndexType>
80 IndexType
gbequ(IndexType m,IndexType n,IndexType kl,IndexType ku,const double * Ab,IndexType ldAb,double * r,double * c,double & rowcnd,double & colcnd,double & amax)81 gbequ(IndexType             m,
82       IndexType             n,
83       IndexType             kl,
84       IndexType             ku,
85       const double          *Ab,
86       IndexType             ldAb,
87       double                *r,
88       double                *c,
89       double                &rowcnd,
90       double                &colcnd,
91       double                &amax)
92 {
93     IndexType info;
94     CXXLAPACK_DEBUG_OUT("dgbequ");
95     LAPACK_IMPL(dgbequ)(&m,
96                         &n,
97                         &kl,
98                         &ku,
99                         Ab,
100                         &ldAb,
101                         r,
102                         c,
103                         &rowcnd,
104                         &colcnd,
105                         &amax,
106                         &info);
107 #   ifndef NDEBUG
108     if (info<0) {
109         std::cerr << "info = " << info << std::endl;
110     }
111 #   endif
112     ASSERT(info>=0);
113     return info;
114 }
115 
116 template <typename IndexType>
117 IndexType
gbequ(IndexType m,IndexType n,IndexType kl,IndexType ku,const std::complex<float> * Ab,IndexType ldAb,float * r,float * c,float & rowcnd,float & colcnd,float & amax)118 gbequ(IndexType                    m,
119       IndexType                    n,
120       IndexType                    kl,
121       IndexType                    ku,
122       const std::complex<float >  *Ab,
123       IndexType                    ldAb,
124       float                        *r,
125       float                        *c,
126       float                        &rowcnd,
127       float                        &colcnd,
128       float                        &amax)
129 {
130     IndexType info;
131     CXXLAPACK_DEBUG_OUT("cgbequ");
132     LAPACK_IMPL(cgbequ)(&m,
133                         &n,
134                         &kl,
135                         &ku,
136                         reinterpret_cast<const float  *>(Ab),
137                         &ldAb,
138                         r,
139                         c,
140                         &rowcnd,
141                         &colcnd,
142                         &amax,
143                         &info);
144 #   ifndef NDEBUG
145     if (info<0) {
146         std::cerr << "info = " << info << std::endl;
147     }
148 #   endif
149     ASSERT(info>=0);
150     return info;
151 }
152 
153 template <typename IndexType>
154 IndexType
gbequ(IndexType m,IndexType n,IndexType kl,IndexType ku,const std::complex<double> * Ab,IndexType ldAb,double * r,double * c,double & rowcnd,double & colcnd,double & amax)155 gbequ(IndexType                    m,
156       IndexType                    n,
157       IndexType                    kl,
158       IndexType                    ku,
159       const std::complex<double>  *Ab,
160       IndexType                    ldAb,
161       double                       *r,
162       double                       *c,
163       double                       &rowcnd,
164       double                       &colcnd,
165       double                       &amax)
166 {
167     IndexType info;
168     CXXLAPACK_DEBUG_OUT("zgbequ");
169     LAPACK_IMPL(zgbequ)(&m,
170                         &n,
171                         &kl,
172                         &ku,
173                         reinterpret_cast<const double *>(Ab),
174                         &ldAb,
175                         r,
176                         c,
177                         &rowcnd,
178                         &colcnd,
179                         &amax,
180                         &info);
181 #   ifndef NDEBUG
182     if (info<0) {
183         std::cerr << "info = " << info << std::endl;
184     }
185 #   endif
186     ASSERT(info>=0);
187     return info;
188 }
189 
190 } // namespace cxxlapack
191 
192 #endif // CXXLAPACK_INTERFACE_GBEQU_TCC
193