1 //
2 // Copyright (c) 2002--2010
3 // Toon Knapen, Karl Meerbergen, Kresimir Fresl,
4 // Thomas Klimpel and Rutger ter Borg
5 //
6 // Distributed under the Boost Software License, Version 1.0.
7 // (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
9 //
10 // THIS FILE IS AUTOMATICALLY GENERATED
11 // PLEASE DO NOT EDIT!
12 //
13 
14 #ifndef BOOST_NUMERIC_BINDINGS_LAPACK_COMPUTATIONAL_SYCON_HPP
15 #define BOOST_NUMERIC_BINDINGS_LAPACK_COMPUTATIONAL_SYCON_HPP
16 
17 #include <boost/assert.hpp>
18 #include <boost/numeric/bindings/begin.hpp>
19 #include <boost/numeric/bindings/detail/array.hpp>
20 #include <boost/numeric/bindings/is_column_major.hpp>
21 #include <boost/numeric/bindings/is_complex.hpp>
22 #include <boost/numeric/bindings/is_mutable.hpp>
23 #include <boost/numeric/bindings/is_real.hpp>
24 #include <boost/numeric/bindings/lapack/workspace.hpp>
25 #include <boost/numeric/bindings/remove_imaginary.hpp>
26 #include <boost/numeric/bindings/size.hpp>
27 #include <boost/numeric/bindings/stride.hpp>
28 #include <boost/numeric/bindings/uplo_tag.hpp>
29 #include <boost/numeric/bindings/value_type.hpp>
30 #include <boost/static_assert.hpp>
31 #include <boost/type_traits/is_same.hpp>
32 #include <boost/type_traits/remove_const.hpp>
33 #include <boost/utility/enable_if.hpp>
34 
35 //
36 // The LAPACK-backend for sycon is the netlib-compatible backend.
37 //
38 #include <boost/numeric/bindings/lapack/detail/lapack.h>
39 #include <boost/numeric/bindings/lapack/detail/lapack_option.hpp>
40 
41 namespace boost {
42 namespace numeric {
43 namespace bindings {
44 namespace lapack {
45 
46 //
47 // The detail namespace contains value-type-overloaded functions that
48 // dispatch to the appropriate back-end LAPACK-routine.
49 //
50 namespace detail {
51 
52 //
53 // Overloaded function for dispatching to
54 // * netlib-compatible LAPACK backend (the default), and
55 // * float value-type.
56 //
57 template< typename UpLo >
sycon(const UpLo,const fortran_int_t n,const float * a,const fortran_int_t lda,const fortran_int_t * ipiv,const float anorm,float & rcond,float * work,fortran_int_t * iwork)58 inline std::ptrdiff_t sycon( const UpLo, const fortran_int_t n, const float* a,
59         const fortran_int_t lda, const fortran_int_t* ipiv, const float anorm,
60         float& rcond, float* work, fortran_int_t* iwork ) {
61     fortran_int_t info(0);
62     LAPACK_SSYCON( &lapack_option< UpLo >::value, &n, a, &lda, ipiv, &anorm,
63             &rcond, work, iwork, &info );
64     return info;
65 }
66 
67 //
68 // Overloaded function for dispatching to
69 // * netlib-compatible LAPACK backend (the default), and
70 // * double value-type.
71 //
72 template< typename UpLo >
sycon(const UpLo,const fortran_int_t n,const double * a,const fortran_int_t lda,const fortran_int_t * ipiv,const double anorm,double & rcond,double * work,fortran_int_t * iwork)73 inline std::ptrdiff_t sycon( const UpLo, const fortran_int_t n,
74         const double* a, const fortran_int_t lda, const fortran_int_t* ipiv,
75         const double anorm, double& rcond, double* work,
76         fortran_int_t* iwork ) {
77     fortran_int_t info(0);
78     LAPACK_DSYCON( &lapack_option< UpLo >::value, &n, a, &lda, ipiv, &anorm,
79             &rcond, work, iwork, &info );
80     return info;
81 }
82 
83 //
84 // Overloaded function for dispatching to
85 // * netlib-compatible LAPACK backend (the default), and
86 // * complex<float> value-type.
87 //
88 template< typename UpLo >
sycon(const UpLo,const fortran_int_t n,const std::complex<float> * a,const fortran_int_t lda,const fortran_int_t * ipiv,const float anorm,float & rcond,std::complex<float> * work)89 inline std::ptrdiff_t sycon( const UpLo, const fortran_int_t n,
90         const std::complex<float>* a, const fortran_int_t lda,
91         const fortran_int_t* ipiv, const float anorm, float& rcond,
92         std::complex<float>* work ) {
93     fortran_int_t info(0);
94     LAPACK_CSYCON( &lapack_option< UpLo >::value, &n, a, &lda, ipiv, &anorm,
95             &rcond, work, &info );
96     return info;
97 }
98 
99 //
100 // Overloaded function for dispatching to
101 // * netlib-compatible LAPACK backend (the default), and
102 // * complex<double> value-type.
103 //
104 template< typename UpLo >
sycon(const UpLo,const fortran_int_t n,const std::complex<double> * a,const fortran_int_t lda,const fortran_int_t * ipiv,const double anorm,double & rcond,std::complex<double> * work)105 inline std::ptrdiff_t sycon( const UpLo, const fortran_int_t n,
106         const std::complex<double>* a, const fortran_int_t lda,
107         const fortran_int_t* ipiv, const double anorm, double& rcond,
108         std::complex<double>* work ) {
109     fortran_int_t info(0);
110     LAPACK_ZSYCON( &lapack_option< UpLo >::value, &n, a, &lda, ipiv, &anorm,
111             &rcond, work, &info );
112     return info;
113 }
114 
115 } // namespace detail
116 
117 //
118 // Value-type based template class. Use this class if you need a type
119 // for dispatching to sycon.
120 //
121 template< typename Value, typename Enable = void >
122 struct sycon_impl {};
123 
124 //
125 // This implementation is enabled if Value is a real type.
126 //
127 template< typename Value >
128 struct sycon_impl< Value, typename boost::enable_if< is_real< Value > >::type > {
129 
130     typedef Value value_type;
131     typedef typename remove_imaginary< Value >::type real_type;
132 
133     //
134     // Static member function for user-defined workspaces, that
135     // * Deduces the required arguments for dispatching to LAPACK, and
136     // * Asserts that most arguments make sense.
137     //
138     template< typename MatrixA, typename VectorIPIV, typename WORK,
139             typename IWORK >
invokeboost::numeric::bindings::lapack::sycon_impl140     static std::ptrdiff_t invoke( const MatrixA& a, const VectorIPIV& ipiv,
141             const real_type anorm, real_type& rcond, detail::workspace2< WORK,
142             IWORK > work ) {
143         namespace bindings = ::boost::numeric::bindings;
144         typedef typename result_of::uplo_tag< MatrixA >::type uplo;
145         BOOST_STATIC_ASSERT( (bindings::is_column_major< MatrixA >::value) );
146         BOOST_ASSERT( bindings::size(ipiv) >= bindings::size_column(a) );
147         BOOST_ASSERT( bindings::size(work.select(fortran_int_t())) >=
148                 min_size_iwork( bindings::size_column(a) ));
149         BOOST_ASSERT( bindings::size(work.select(real_type())) >=
150                 min_size_work( bindings::size_column(a) ));
151         BOOST_ASSERT( bindings::size_column(a) >= 0 );
152         BOOST_ASSERT( bindings::size_minor(a) == 1 ||
153                 bindings::stride_minor(a) == 1 );
154         BOOST_ASSERT( bindings::stride_major(a) >= std::max< std::ptrdiff_t >(1,
155                 bindings::size_column(a)) );
156         return detail::sycon( uplo(), bindings::size_column(a),
157                 bindings::begin_value(a), bindings::stride_major(a),
158                 bindings::begin_value(ipiv), anorm, rcond,
159                 bindings::begin_value(work.select(real_type())),
160                 bindings::begin_value(work.select(fortran_int_t())) );
161     }
162 
163     //
164     // Static member function that
165     // * Figures out the minimal workspace requirements, and passes
166     //   the results to the user-defined workspace overload of the
167     //   invoke static member function
168     // * Enables the unblocked algorithm (BLAS level 2)
169     //
170     template< typename MatrixA, typename VectorIPIV >
invokeboost::numeric::bindings::lapack::sycon_impl171     static std::ptrdiff_t invoke( const MatrixA& a, const VectorIPIV& ipiv,
172             const real_type anorm, real_type& rcond, minimal_workspace ) {
173         namespace bindings = ::boost::numeric::bindings;
174         typedef typename result_of::uplo_tag< MatrixA >::type uplo;
175         bindings::detail::array< real_type > tmp_work( min_size_work(
176                 bindings::size_column(a) ) );
177         bindings::detail::array< fortran_int_t > tmp_iwork(
178                 min_size_iwork( bindings::size_column(a) ) );
179         return invoke( a, ipiv, anorm, rcond, workspace( tmp_work,
180                 tmp_iwork ) );
181     }
182 
183     //
184     // Static member function that
185     // * Figures out the optimal workspace requirements, and passes
186     //   the results to the user-defined workspace overload of the
187     //   invoke static member
188     // * Enables the blocked algorithm (BLAS level 3)
189     //
190     template< typename MatrixA, typename VectorIPIV >
invokeboost::numeric::bindings::lapack::sycon_impl191     static std::ptrdiff_t invoke( const MatrixA& a, const VectorIPIV& ipiv,
192             const real_type anorm, real_type& rcond, optimal_workspace ) {
193         namespace bindings = ::boost::numeric::bindings;
194         typedef typename result_of::uplo_tag< MatrixA >::type uplo;
195         return invoke( a, ipiv, anorm, rcond, minimal_workspace() );
196     }
197 
198     //
199     // Static member function that returns the minimum size of
200     // workspace-array work.
201     //
min_size_workboost::numeric::bindings::lapack::sycon_impl202     static std::ptrdiff_t min_size_work( const std::ptrdiff_t n ) {
203         return 2*n;
204     }
205 
206     //
207     // Static member function that returns the minimum size of
208     // workspace-array iwork.
209     //
min_size_iworkboost::numeric::bindings::lapack::sycon_impl210     static std::ptrdiff_t min_size_iwork( const std::ptrdiff_t n ) {
211         return n;
212     }
213 };
214 
215 //
216 // This implementation is enabled if Value is a complex type.
217 //
218 template< typename Value >
219 struct sycon_impl< Value, typename boost::enable_if< is_complex< Value > >::type > {
220 
221     typedef Value value_type;
222     typedef typename remove_imaginary< Value >::type real_type;
223 
224     //
225     // Static member function for user-defined workspaces, that
226     // * Deduces the required arguments for dispatching to LAPACK, and
227     // * Asserts that most arguments make sense.
228     //
229     template< typename MatrixA, typename VectorIPIV, typename WORK >
invokeboost::numeric::bindings::lapack::sycon_impl230     static std::ptrdiff_t invoke( const MatrixA& a, const VectorIPIV& ipiv,
231             const real_type anorm, real_type& rcond, detail::workspace1<
232             WORK > work ) {
233         namespace bindings = ::boost::numeric::bindings;
234         typedef typename result_of::uplo_tag< MatrixA >::type uplo;
235         BOOST_STATIC_ASSERT( (bindings::is_column_major< MatrixA >::value) );
236         BOOST_ASSERT( bindings::size(ipiv) >= bindings::size_column(a) );
237         BOOST_ASSERT( bindings::size(work.select(value_type())) >=
238                 min_size_work( bindings::size_column(a) ));
239         BOOST_ASSERT( bindings::size_column(a) >= 0 );
240         BOOST_ASSERT( bindings::size_minor(a) == 1 ||
241                 bindings::stride_minor(a) == 1 );
242         BOOST_ASSERT( bindings::stride_major(a) >= std::max< std::ptrdiff_t >(1,
243                 bindings::size_column(a)) );
244         return detail::sycon( uplo(), bindings::size_column(a),
245                 bindings::begin_value(a), bindings::stride_major(a),
246                 bindings::begin_value(ipiv), anorm, rcond,
247                 bindings::begin_value(work.select(value_type())) );
248     }
249 
250     //
251     // Static member function that
252     // * Figures out the minimal workspace requirements, and passes
253     //   the results to the user-defined workspace overload of the
254     //   invoke static member function
255     // * Enables the unblocked algorithm (BLAS level 2)
256     //
257     template< typename MatrixA, typename VectorIPIV >
invokeboost::numeric::bindings::lapack::sycon_impl258     static std::ptrdiff_t invoke( const MatrixA& a, const VectorIPIV& ipiv,
259             const real_type anorm, real_type& rcond, minimal_workspace ) {
260         namespace bindings = ::boost::numeric::bindings;
261         typedef typename result_of::uplo_tag< MatrixA >::type uplo;
262         bindings::detail::array< value_type > tmp_work( min_size_work(
263                 bindings::size_column(a) ) );
264         return invoke( a, ipiv, anorm, rcond, workspace( tmp_work ) );
265     }
266 
267     //
268     // Static member function that
269     // * Figures out the optimal workspace requirements, and passes
270     //   the results to the user-defined workspace overload of the
271     //   invoke static member
272     // * Enables the blocked algorithm (BLAS level 3)
273     //
274     template< typename MatrixA, typename VectorIPIV >
invokeboost::numeric::bindings::lapack::sycon_impl275     static std::ptrdiff_t invoke( const MatrixA& a, const VectorIPIV& ipiv,
276             const real_type anorm, real_type& rcond, optimal_workspace ) {
277         namespace bindings = ::boost::numeric::bindings;
278         typedef typename result_of::uplo_tag< MatrixA >::type uplo;
279         return invoke( a, ipiv, anorm, rcond, minimal_workspace() );
280     }
281 
282     //
283     // Static member function that returns the minimum size of
284     // workspace-array work.
285     //
min_size_workboost::numeric::bindings::lapack::sycon_impl286     static std::ptrdiff_t min_size_work( const std::ptrdiff_t n ) {
287         return 2*n;
288     }
289 };
290 
291 
292 //
293 // Functions for direct use. These functions are overloaded for temporaries,
294 // so that wrapped types can still be passed and used for write-access. In
295 // addition, if applicable, they are overloaded for user-defined workspaces.
296 // Calls to these functions are passed to the sycon_impl classes. In the
297 // documentation, most overloads are collapsed to avoid a large number of
298 // prototypes which are very similar.
299 //
300 
301 //
302 // Overloaded function for sycon. Its overload differs for
303 // * User-defined workspace
304 //
305 template< typename MatrixA, typename VectorIPIV, typename Workspace >
306 inline typename boost::enable_if< detail::is_workspace< Workspace >,
307         std::ptrdiff_t >::type
sycon(const MatrixA & a,const VectorIPIV & ipiv,const typename remove_imaginary<typename bindings::value_type<MatrixA>::type>::type anorm,typename remove_imaginary<typename bindings::value_type<MatrixA>::type>::type & rcond,Workspace work)308 sycon( const MatrixA& a, const VectorIPIV& ipiv,
309         const typename remove_imaginary< typename bindings::value_type<
310         MatrixA >::type >::type anorm, typename remove_imaginary<
311         typename bindings::value_type< MatrixA >::type >::type& rcond,
312         Workspace work ) {
313     return sycon_impl< typename bindings::value_type<
314             MatrixA >::type >::invoke( a, ipiv, anorm, rcond, work );
315 }
316 
317 //
318 // Overloaded function for sycon. Its overload differs for
319 // * Default workspace-type (optimal)
320 //
321 template< typename MatrixA, typename VectorIPIV >
322 inline typename boost::disable_if< detail::is_workspace< VectorIPIV >,
323         std::ptrdiff_t >::type
sycon(const MatrixA & a,const VectorIPIV & ipiv,const typename remove_imaginary<typename bindings::value_type<MatrixA>::type>::type anorm,typename remove_imaginary<typename bindings::value_type<MatrixA>::type>::type & rcond)324 sycon( const MatrixA& a, const VectorIPIV& ipiv,
325         const typename remove_imaginary< typename bindings::value_type<
326         MatrixA >::type >::type anorm, typename remove_imaginary<
327         typename bindings::value_type< MatrixA >::type >::type& rcond ) {
328     return sycon_impl< typename bindings::value_type<
329             MatrixA >::type >::invoke( a, ipiv, anorm, rcond,
330             optimal_workspace() );
331 }
332 
333 } // namespace lapack
334 } // namespace bindings
335 } // namespace numeric
336 } // namespace boost
337 
338 #endif
339