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_SYTRF_TCC
34 #define CXXLAPACK_INTERFACE_SYTRF_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
sytrf(char uplo,IndexType n,float * A,IndexType ldA,IndexType * iPiv,float * work,IndexType lWork)44 sytrf(char                  uplo,
45       IndexType             n,
46       float                 *A,
47       IndexType             ldA,
48       IndexType             *iPiv,
49       float                 *work,
50       IndexType             lWork)
51 {
52     CXXLAPACK_DEBUG_OUT("ssytrf");
53 
54     IndexType info;
55     LAPACK_IMPL(ssytrf)(&uplo,
56                         &n,
57                         A,
58                         &ldA,
59                         iPiv,
60                         work,
61                         &lWork,
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
sytrf(char uplo,IndexType n,double * A,IndexType ldA,IndexType * iPiv,double * work,IndexType lWork)74 sytrf(char                  uplo,
75       IndexType             n,
76       double                *A,
77       IndexType             ldA,
78       IndexType             *iPiv,
79       double                *work,
80       IndexType             lWork)
81 {
82     CXXLAPACK_DEBUG_OUT("dsytrf");
83 
84     IndexType info;
85     LAPACK_IMPL(dsytrf)(&uplo,
86                         &n,
87                         A,
88                         &ldA,
89                         iPiv,
90                         work,
91                         &lWork,
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 template <typename IndexType>
103 IndexType
sytrf(char uplo,IndexType n,std::complex<float> * A,IndexType ldA,IndexType * iPiv,std::complex<float> * work,IndexType lWork)104 sytrf(char                  uplo,
105       IndexType             n,
106       std::complex<float >  *A,
107       IndexType             ldA,
108       IndexType             *iPiv,
109       std::complex<float >  *work,
110       IndexType             lWork)
111 {
112     CXXLAPACK_DEBUG_OUT("csytrf");
113 
114     IndexType info;
115     LAPACK_IMPL(csytrf)(&uplo,
116                         &n,
117                         reinterpret_cast<float  *>(A),
118                         &ldA,
119                         iPiv,
120                         reinterpret_cast<float  *>(work),
121                         &lWork,
122                         &info);
123 #   ifndef NDEBUG
124     if (info<0) {
125         std::cerr << "info = " << info << std::endl;
126     }
127 #   endif
128     ASSERT(info>=0);
129     return info;
130 }
131 
132 template <typename IndexType>
133 IndexType
sytrf(char uplo,IndexType n,std::complex<double> * A,IndexType ldA,IndexType * iPiv,std::complex<double> * work,IndexType lWork)134 sytrf(char                  uplo,
135       IndexType             n,
136       std::complex<double>  *A,
137       IndexType             ldA,
138       IndexType             *iPiv,
139       std::complex<double>  *work,
140       IndexType             lWork)
141 {
142     CXXLAPACK_DEBUG_OUT("zsytrf");
143 
144     IndexType info;
145     LAPACK_IMPL(zsytrf)(&uplo,
146                         &n,
147                         reinterpret_cast<double *>(A),
148                         &ldA,
149                         iPiv,
150                         reinterpret_cast<double *>(work),
151                         &lWork,
152                         &info);
153 #   ifndef NDEBUG
154     if (info<0) {
155         std::cerr << "info = " << info << std::endl;
156     }
157 #   endif
158     ASSERT(info>=0);
159     return info;
160 }
161 
162 } // namespace cxxlapack
163 
164 #endif // CXXLAPACK_INTERFACE_SYTRF_TCC
165