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