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_DRIVER_GTSV_HPP
15 #define BOOST_NUMERIC_BINDINGS_LAPACK_DRIVER_GTSV_HPP
16 
17 #include <boost/assert.hpp>
18 #include <boost/numeric/bindings/begin.hpp>
19 #include <boost/numeric/bindings/is_column_major.hpp>
20 #include <boost/numeric/bindings/is_mutable.hpp>
21 #include <boost/numeric/bindings/remove_imaginary.hpp>
22 #include <boost/numeric/bindings/size.hpp>
23 #include <boost/numeric/bindings/stride.hpp>
24 #include <boost/numeric/bindings/value_type.hpp>
25 #include <boost/static_assert.hpp>
26 #include <boost/type_traits/is_same.hpp>
27 #include <boost/type_traits/remove_const.hpp>
28 
29 //
30 // The LAPACK-backend for gtsv is the netlib-compatible backend.
31 //
32 #include <boost/numeric/bindings/lapack/detail/lapack.h>
33 #include <boost/numeric/bindings/lapack/detail/lapack_option.hpp>
34 
35 namespace boost {
36 namespace numeric {
37 namespace bindings {
38 namespace lapack {
39 
40 //
41 // The detail namespace contains value-type-overloaded functions that
42 // dispatch to the appropriate back-end LAPACK-routine.
43 //
44 namespace detail {
45 
46 //
47 // Overloaded function for dispatching to
48 // * netlib-compatible LAPACK backend (the default), and
49 // * float value-type.
50 //
gtsv(const fortran_int_t n,const fortran_int_t nrhs,float * dl,float * d,float * du,float * b,const fortran_int_t ldb)51 inline std::ptrdiff_t gtsv( const fortran_int_t n, const fortran_int_t nrhs,
52         float* dl, float* d, float* du, float* b, const fortran_int_t ldb ) {
53     fortran_int_t info(0);
54     LAPACK_SGTSV( &n, &nrhs, dl, d, du, b, &ldb, &info );
55     return info;
56 }
57 
58 //
59 // Overloaded function for dispatching to
60 // * netlib-compatible LAPACK backend (the default), and
61 // * double value-type.
62 //
gtsv(const fortran_int_t n,const fortran_int_t nrhs,double * dl,double * d,double * du,double * b,const fortran_int_t ldb)63 inline std::ptrdiff_t gtsv( const fortran_int_t n, const fortran_int_t nrhs,
64         double* dl, double* d, double* du, double* b,
65         const fortran_int_t ldb ) {
66     fortran_int_t info(0);
67     LAPACK_DGTSV( &n, &nrhs, dl, d, du, b, &ldb, &info );
68     return info;
69 }
70 
71 //
72 // Overloaded function for dispatching to
73 // * netlib-compatible LAPACK backend (the default), and
74 // * complex<float> value-type.
75 //
gtsv(const fortran_int_t n,const fortran_int_t nrhs,std::complex<float> * dl,std::complex<float> * d,std::complex<float> * du,std::complex<float> * b,const fortran_int_t ldb)76 inline std::ptrdiff_t gtsv( const fortran_int_t n, const fortran_int_t nrhs,
77         std::complex<float>* dl, std::complex<float>* d,
78         std::complex<float>* du, std::complex<float>* b,
79         const fortran_int_t ldb ) {
80     fortran_int_t info(0);
81     LAPACK_CGTSV( &n, &nrhs, dl, d, du, b, &ldb, &info );
82     return info;
83 }
84 
85 //
86 // Overloaded function for dispatching to
87 // * netlib-compatible LAPACK backend (the default), and
88 // * complex<double> value-type.
89 //
gtsv(const fortran_int_t n,const fortran_int_t nrhs,std::complex<double> * dl,std::complex<double> * d,std::complex<double> * du,std::complex<double> * b,const fortran_int_t ldb)90 inline std::ptrdiff_t gtsv( const fortran_int_t n, const fortran_int_t nrhs,
91         std::complex<double>* dl, std::complex<double>* d,
92         std::complex<double>* du, std::complex<double>* b,
93         const fortran_int_t ldb ) {
94     fortran_int_t info(0);
95     LAPACK_ZGTSV( &n, &nrhs, dl, d, du, b, &ldb, &info );
96     return info;
97 }
98 
99 } // namespace detail
100 
101 //
102 // Value-type based template class. Use this class if you need a type
103 // for dispatching to gtsv.
104 //
105 template< typename Value >
106 struct gtsv_impl {
107 
108     typedef Value value_type;
109     typedef typename remove_imaginary< Value >::type real_type;
110 
111     //
112     // Static member function, that
113     // * Deduces the required arguments for dispatching to LAPACK, and
114     // * Asserts that most arguments make sense.
115     //
116     template< typename VectorDL, typename VectorD, typename VectorDU,
117             typename MatrixB >
invokeboost::numeric::bindings::lapack::gtsv_impl118     static std::ptrdiff_t invoke( const fortran_int_t n, VectorDL& dl,
119             VectorD& d, VectorDU& du, MatrixB& b ) {
120         namespace bindings = ::boost::numeric::bindings;
121         BOOST_STATIC_ASSERT( (bindings::is_column_major< MatrixB >::value) );
122         BOOST_STATIC_ASSERT( (boost::is_same< typename remove_const<
123                 typename bindings::value_type< VectorDL >::type >::type,
124                 typename remove_const< typename bindings::value_type<
125                 VectorD >::type >::type >::value) );
126         BOOST_STATIC_ASSERT( (boost::is_same< typename remove_const<
127                 typename bindings::value_type< VectorDL >::type >::type,
128                 typename remove_const< typename bindings::value_type<
129                 VectorDU >::type >::type >::value) );
130         BOOST_STATIC_ASSERT( (boost::is_same< typename remove_const<
131                 typename bindings::value_type< VectorDL >::type >::type,
132                 typename remove_const< typename bindings::value_type<
133                 MatrixB >::type >::type >::value) );
134         BOOST_STATIC_ASSERT( (bindings::is_mutable< VectorDL >::value) );
135         BOOST_STATIC_ASSERT( (bindings::is_mutable< VectorD >::value) );
136         BOOST_STATIC_ASSERT( (bindings::is_mutable< VectorDU >::value) );
137         BOOST_STATIC_ASSERT( (bindings::is_mutable< MatrixB >::value) );
138         BOOST_ASSERT( bindings::size(d) >= n );
139         BOOST_ASSERT( bindings::size(dl) >= n-1 );
140         BOOST_ASSERT( bindings::size(du) >= n-1 );
141         BOOST_ASSERT( bindings::size_column(b) >= 0 );
142         BOOST_ASSERT( bindings::size_minor(b) == 1 ||
143                 bindings::stride_minor(b) == 1 );
144         BOOST_ASSERT( bindings::stride_major(b) >= std::max< std::ptrdiff_t >(1,
145                 n) );
146         BOOST_ASSERT( n >= 0 );
147         return detail::gtsv( n, bindings::size_column(b),
148                 bindings::begin_value(dl), bindings::begin_value(d),
149                 bindings::begin_value(du), bindings::begin_value(b),
150                 bindings::stride_major(b) );
151     }
152 
153 };
154 
155 
156 //
157 // Functions for direct use. These functions are overloaded for temporaries,
158 // so that wrapped types can still be passed and used for write-access. In
159 // addition, if applicable, they are overloaded for user-defined workspaces.
160 // Calls to these functions are passed to the gtsv_impl classes. In the
161 // documentation, most overloads are collapsed to avoid a large number of
162 // prototypes which are very similar.
163 //
164 
165 //
166 // Overloaded function for gtsv. Its overload differs for
167 //
168 template< typename VectorDL, typename VectorD, typename VectorDU,
169         typename MatrixB >
gtsv(const fortran_int_t n,VectorDL & dl,VectorD & d,VectorDU & du,MatrixB & b)170 inline std::ptrdiff_t gtsv( const fortran_int_t n, VectorDL& dl,
171         VectorD& d, VectorDU& du, MatrixB& b ) {
172     return gtsv_impl< typename bindings::value_type<
173             VectorDL >::type >::invoke( n, dl, d, du, b );
174 }
175 
176 } // namespace lapack
177 } // namespace bindings
178 } // namespace numeric
179 } // namespace boost
180 
181 #endif
182