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_SBEVX_HPP
15 #define BOOST_NUMERIC_BINDINGS_LAPACK_DRIVER_SBEVX_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/detail/array.hpp>
21 #include <boost/numeric/bindings/is_column_major.hpp>
22 #include <boost/numeric/bindings/is_mutable.hpp>
23 #include <boost/numeric/bindings/lapack/workspace.hpp>
24 #include <boost/numeric/bindings/remove_imaginary.hpp>
25 #include <boost/numeric/bindings/size.hpp>
26 #include <boost/numeric/bindings/stride.hpp>
27 #include <boost/numeric/bindings/uplo_tag.hpp>
28 #include <boost/numeric/bindings/value_type.hpp>
29 #include <boost/static_assert.hpp>
30 #include <boost/type_traits/is_same.hpp>
31 #include <boost/type_traits/remove_const.hpp>
32 
33 //
34 // The LAPACK-backend for sbevx is the netlib-compatible backend.
35 //
36 #include <boost/numeric/bindings/lapack/detail/lapack.h>
37 #include <boost/numeric/bindings/lapack/detail/lapack_option.hpp>
38 
39 namespace boost {
40 namespace numeric {
41 namespace bindings {
42 namespace lapack {
43 
44 //
45 // The detail namespace contains value-type-overloaded functions that
46 // dispatch to the appropriate back-end LAPACK-routine.
47 //
48 namespace detail {
49 
50 //
51 // Overloaded function for dispatching to
52 // * netlib-compatible LAPACK backend (the default), and
53 // * float value-type.
54 //
55 template< typename UpLo >
sbevx(const char jobz,const char range,const UpLo,const fortran_int_t n,const fortran_int_t kd,float * ab,const fortran_int_t ldab,float * q,const fortran_int_t ldq,const float vl,const float vu,const fortran_int_t il,const fortran_int_t iu,const float abstol,fortran_int_t & m,float * w,float * z,const fortran_int_t ldz,float * work,fortran_int_t * iwork,fortran_int_t * ifail)56 inline std::ptrdiff_t sbevx( const char jobz, const char range, const UpLo,
57         const fortran_int_t n, const fortran_int_t kd, float* ab,
58         const fortran_int_t ldab, float* q, const fortran_int_t ldq,
59         const float vl, const float vu, const fortran_int_t il,
60         const fortran_int_t iu, const float abstol, fortran_int_t& m,
61         float* w, float* z, const fortran_int_t ldz, float* work,
62         fortran_int_t* iwork, fortran_int_t* ifail ) {
63     fortran_int_t info(0);
64     LAPACK_SSBEVX( &jobz, &range, &lapack_option< UpLo >::value, &n, &kd, ab,
65             &ldab, q, &ldq, &vl, &vu, &il, &iu, &abstol, &m, w, z, &ldz, work,
66             iwork, ifail, &info );
67     return info;
68 }
69 
70 //
71 // Overloaded function for dispatching to
72 // * netlib-compatible LAPACK backend (the default), and
73 // * double value-type.
74 //
75 template< typename UpLo >
sbevx(const char jobz,const char range,const UpLo,const fortran_int_t n,const fortran_int_t kd,double * ab,const fortran_int_t ldab,double * q,const fortran_int_t ldq,const double vl,const double vu,const fortran_int_t il,const fortran_int_t iu,const double abstol,fortran_int_t & m,double * w,double * z,const fortran_int_t ldz,double * work,fortran_int_t * iwork,fortran_int_t * ifail)76 inline std::ptrdiff_t sbevx( const char jobz, const char range, const UpLo,
77         const fortran_int_t n, const fortran_int_t kd, double* ab,
78         const fortran_int_t ldab, double* q, const fortran_int_t ldq,
79         const double vl, const double vu, const fortran_int_t il,
80         const fortran_int_t iu, const double abstol, fortran_int_t& m,
81         double* w, double* z, const fortran_int_t ldz, double* work,
82         fortran_int_t* iwork, fortran_int_t* ifail ) {
83     fortran_int_t info(0);
84     LAPACK_DSBEVX( &jobz, &range, &lapack_option< UpLo >::value, &n, &kd, ab,
85             &ldab, q, &ldq, &vl, &vu, &il, &iu, &abstol, &m, w, z, &ldz, work,
86             iwork, ifail, &info );
87     return info;
88 }
89 
90 } // namespace detail
91 
92 //
93 // Value-type based template class. Use this class if you need a type
94 // for dispatching to sbevx.
95 //
96 template< typename Value >
97 struct sbevx_impl {
98 
99     typedef Value value_type;
100     typedef typename remove_imaginary< Value >::type real_type;
101 
102     //
103     // Static member function for user-defined workspaces, that
104     // * Deduces the required arguments for dispatching to LAPACK, and
105     // * Asserts that most arguments make sense.
106     //
107     template< typename MatrixAB, typename MatrixQ, typename VectorW,
108             typename MatrixZ, typename VectorIFAIL, typename WORK,
109             typename IWORK >
invokeboost::numeric::bindings::lapack::sbevx_impl110     static std::ptrdiff_t invoke( const char jobz, const char range,
111             MatrixAB& ab, MatrixQ& q, const real_type vl, const real_type vu,
112             const fortran_int_t il, const fortran_int_t iu,
113             const real_type abstol, fortran_int_t& m, VectorW& w,
114             MatrixZ& z, VectorIFAIL& ifail, detail::workspace2< WORK,
115             IWORK > work ) {
116         namespace bindings = ::boost::numeric::bindings;
117         typedef typename result_of::uplo_tag< MatrixAB >::type uplo;
118         BOOST_STATIC_ASSERT( (bindings::is_column_major< MatrixAB >::value) );
119         BOOST_STATIC_ASSERT( (bindings::is_column_major< MatrixQ >::value) );
120         BOOST_STATIC_ASSERT( (bindings::is_column_major< MatrixZ >::value) );
121         BOOST_STATIC_ASSERT( (boost::is_same< typename remove_const<
122                 typename bindings::value_type< MatrixAB >::type >::type,
123                 typename remove_const< typename bindings::value_type<
124                 MatrixQ >::type >::type >::value) );
125         BOOST_STATIC_ASSERT( (boost::is_same< typename remove_const<
126                 typename bindings::value_type< MatrixAB >::type >::type,
127                 typename remove_const< typename bindings::value_type<
128                 VectorW >::type >::type >::value) );
129         BOOST_STATIC_ASSERT( (boost::is_same< typename remove_const<
130                 typename bindings::value_type< MatrixAB >::type >::type,
131                 typename remove_const< typename bindings::value_type<
132                 MatrixZ >::type >::type >::value) );
133         BOOST_STATIC_ASSERT( (bindings::is_mutable< MatrixAB >::value) );
134         BOOST_STATIC_ASSERT( (bindings::is_mutable< MatrixQ >::value) );
135         BOOST_STATIC_ASSERT( (bindings::is_mutable< VectorW >::value) );
136         BOOST_STATIC_ASSERT( (bindings::is_mutable< MatrixZ >::value) );
137         BOOST_STATIC_ASSERT( (bindings::is_mutable< VectorIFAIL >::value) );
138         BOOST_ASSERT( bindings::bandwidth(ab, uplo()) >= 0 );
139         BOOST_ASSERT( bindings::size(w) >= bindings::size_column(ab) );
140         BOOST_ASSERT( bindings::size(work.select(fortran_int_t())) >=
141                 min_size_iwork( bindings::size_column(ab) ));
142         BOOST_ASSERT( bindings::size(work.select(real_type())) >=
143                 min_size_work( bindings::size_column(ab) ));
144         BOOST_ASSERT( bindings::size_column(ab) >= 0 );
145         BOOST_ASSERT( bindings::size_minor(ab) == 1 ||
146                 bindings::stride_minor(ab) == 1 );
147         BOOST_ASSERT( bindings::size_minor(q) == 1 ||
148                 bindings::stride_minor(q) == 1 );
149         BOOST_ASSERT( bindings::size_minor(z) == 1 ||
150                 bindings::stride_minor(z) == 1 );
151         BOOST_ASSERT( bindings::stride_major(ab) >= bindings::bandwidth(ab,
152                 uplo())+1 );
153         BOOST_ASSERT( bindings::stride_major(q) >= std::max< std::ptrdiff_t >(1,
154                 bindings::size_column(ab)) );
155         BOOST_ASSERT( jobz == 'N' || jobz == 'V' );
156         BOOST_ASSERT( range == 'A' || range == 'V' || range == 'I' );
157         return detail::sbevx( jobz, range, uplo(), bindings::size_column(ab),
158                 bindings::bandwidth(ab, uplo()), bindings::begin_value(ab),
159                 bindings::stride_major(ab), bindings::begin_value(q),
160                 bindings::stride_major(q), vl, vu, il, iu, abstol, m,
161                 bindings::begin_value(w), bindings::begin_value(z),
162                 bindings::stride_major(z),
163                 bindings::begin_value(work.select(real_type())),
164                 bindings::begin_value(work.select(fortran_int_t())),
165                 bindings::begin_value(ifail) );
166     }
167 
168     //
169     // Static member function that
170     // * Figures out the minimal workspace requirements, and passes
171     //   the results to the user-defined workspace overload of the
172     //   invoke static member function
173     // * Enables the unblocked algorithm (BLAS level 2)
174     //
175     template< typename MatrixAB, typename MatrixQ, typename VectorW,
176             typename MatrixZ, typename VectorIFAIL >
invokeboost::numeric::bindings::lapack::sbevx_impl177     static std::ptrdiff_t invoke( const char jobz, const char range,
178             MatrixAB& ab, MatrixQ& q, const real_type vl, const real_type vu,
179             const fortran_int_t il, const fortran_int_t iu,
180             const real_type abstol, fortran_int_t& m, VectorW& w,
181             MatrixZ& z, VectorIFAIL& ifail, minimal_workspace ) {
182         namespace bindings = ::boost::numeric::bindings;
183         typedef typename result_of::uplo_tag< MatrixAB >::type uplo;
184         bindings::detail::array< real_type > tmp_work( min_size_work(
185                 bindings::size_column(ab) ) );
186         bindings::detail::array< fortran_int_t > tmp_iwork(
187                 min_size_iwork( bindings::size_column(ab) ) );
188         return invoke( jobz, range, ab, q, vl, vu, il, iu, abstol, m, w, z,
189                 ifail, workspace( tmp_work, tmp_iwork ) );
190     }
191 
192     //
193     // Static member function that
194     // * Figures out the optimal workspace requirements, and passes
195     //   the results to the user-defined workspace overload of the
196     //   invoke static member
197     // * Enables the blocked algorithm (BLAS level 3)
198     //
199     template< typename MatrixAB, typename MatrixQ, typename VectorW,
200             typename MatrixZ, typename VectorIFAIL >
invokeboost::numeric::bindings::lapack::sbevx_impl201     static std::ptrdiff_t invoke( const char jobz, const char range,
202             MatrixAB& ab, MatrixQ& q, const real_type vl, const real_type vu,
203             const fortran_int_t il, const fortran_int_t iu,
204             const real_type abstol, fortran_int_t& m, VectorW& w,
205             MatrixZ& z, VectorIFAIL& ifail, optimal_workspace ) {
206         namespace bindings = ::boost::numeric::bindings;
207         typedef typename result_of::uplo_tag< MatrixAB >::type uplo;
208         return invoke( jobz, range, ab, q, vl, vu, il, iu, abstol, m, w, z,
209                 ifail, minimal_workspace() );
210     }
211 
212     //
213     // Static member function that returns the minimum size of
214     // workspace-array work.
215     //
min_size_workboost::numeric::bindings::lapack::sbevx_impl216     static std::ptrdiff_t min_size_work( const std::ptrdiff_t n ) {
217         return 7*n;
218     }
219 
220     //
221     // Static member function that returns the minimum size of
222     // workspace-array iwork.
223     //
min_size_iworkboost::numeric::bindings::lapack::sbevx_impl224     static std::ptrdiff_t min_size_iwork( const std::ptrdiff_t n ) {
225         return 5*n;
226     }
227 };
228 
229 
230 //
231 // Functions for direct use. These functions are overloaded for temporaries,
232 // so that wrapped types can still be passed and used for write-access. In
233 // addition, if applicable, they are overloaded for user-defined workspaces.
234 // Calls to these functions are passed to the sbevx_impl classes. In the
235 // documentation, most overloads are collapsed to avoid a large number of
236 // prototypes which are very similar.
237 //
238 
239 //
240 // Overloaded function for sbevx. Its overload differs for
241 // * User-defined workspace
242 //
243 template< typename MatrixAB, typename MatrixQ, typename VectorW,
244         typename MatrixZ, typename VectorIFAIL, typename Workspace >
245 inline typename boost::enable_if< detail::is_workspace< Workspace >,
246         std::ptrdiff_t >::type
sbevx(const char jobz,const char range,MatrixAB & ab,MatrixQ & q,const typename remove_imaginary<typename bindings::value_type<MatrixAB>::type>::type vl,const typename remove_imaginary<typename bindings::value_type<MatrixAB>::type>::type vu,const fortran_int_t il,const fortran_int_t iu,const typename remove_imaginary<typename bindings::value_type<MatrixAB>::type>::type abstol,fortran_int_t & m,VectorW & w,MatrixZ & z,VectorIFAIL & ifail,Workspace work)247 sbevx( const char jobz, const char range, MatrixAB& ab, MatrixQ& q,
248         const typename remove_imaginary< typename bindings::value_type<
249         MatrixAB >::type >::type vl, const typename remove_imaginary<
250         typename bindings::value_type< MatrixAB >::type >::type vu,
251         const fortran_int_t il, const fortran_int_t iu,
252         const typename remove_imaginary< typename bindings::value_type<
253         MatrixAB >::type >::type abstol, fortran_int_t& m, VectorW& w,
254         MatrixZ& z, VectorIFAIL& ifail, Workspace work ) {
255     return sbevx_impl< typename bindings::value_type<
256             MatrixAB >::type >::invoke( jobz, range, ab, q, vl, vu, il, iu,
257             abstol, m, w, z, ifail, work );
258 }
259 
260 //
261 // Overloaded function for sbevx. Its overload differs for
262 // * Default workspace-type (optimal)
263 //
264 template< typename MatrixAB, typename MatrixQ, typename VectorW,
265         typename MatrixZ, typename VectorIFAIL >
266 inline typename boost::disable_if< detail::is_workspace< VectorIFAIL >,
267         std::ptrdiff_t >::type
sbevx(const char jobz,const char range,MatrixAB & ab,MatrixQ & q,const typename remove_imaginary<typename bindings::value_type<MatrixAB>::type>::type vl,const typename remove_imaginary<typename bindings::value_type<MatrixAB>::type>::type vu,const fortran_int_t il,const fortran_int_t iu,const typename remove_imaginary<typename bindings::value_type<MatrixAB>::type>::type abstol,fortran_int_t & m,VectorW & w,MatrixZ & z,VectorIFAIL & ifail)268 sbevx( const char jobz, const char range, MatrixAB& ab, MatrixQ& q,
269         const typename remove_imaginary< typename bindings::value_type<
270         MatrixAB >::type >::type vl, const typename remove_imaginary<
271         typename bindings::value_type< MatrixAB >::type >::type vu,
272         const fortran_int_t il, const fortran_int_t iu,
273         const typename remove_imaginary< typename bindings::value_type<
274         MatrixAB >::type >::type abstol, fortran_int_t& m, VectorW& w,
275         MatrixZ& z, VectorIFAIL& ifail ) {
276     return sbevx_impl< typename bindings::value_type<
277             MatrixAB >::type >::invoke( jobz, range, ab, q, vl, vu, il, iu,
278             abstol, m, w, z, ifail, optimal_workspace() );
279 }
280 
281 } // namespace lapack
282 } // namespace bindings
283 } // namespace numeric
284 } // namespace boost
285 
286 #endif
287