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