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