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_STEVX_HPP
15 #define BOOST_NUMERIC_BINDINGS_LAPACK_DRIVER_STEVX_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_mutable.hpp>
22 #include <boost/numeric/bindings/lapack/workspace.hpp>
23 #include <boost/numeric/bindings/remove_imaginary.hpp>
24 #include <boost/numeric/bindings/size.hpp>
25 #include <boost/numeric/bindings/stride.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 stevx 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 //
stevx(const char jobz,const char range,const fortran_int_t n,float * d,float * e,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)53 inline std::ptrdiff_t stevx( const char jobz, const char range,
54         const fortran_int_t n, float* d, float* e, const float vl,
55         const float vu, const fortran_int_t il, const fortran_int_t iu,
56         const float abstol, fortran_int_t& m, float* w, float* z,
57         const fortran_int_t ldz, float* work, fortran_int_t* iwork,
58         fortran_int_t* ifail ) {
59     fortran_int_t info(0);
60     LAPACK_SSTEVX( &jobz, &range, &n, d, e, &vl, &vu, &il, &iu, &abstol, &m,
61             w, z, &ldz, work, iwork, ifail, &info );
62     return info;
63 }
64 
65 //
66 // Overloaded function for dispatching to
67 // * netlib-compatible LAPACK backend (the default), and
68 // * double value-type.
69 //
stevx(const char jobz,const char range,const fortran_int_t n,double * d,double * e,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)70 inline std::ptrdiff_t stevx( const char jobz, const char range,
71         const fortran_int_t n, double* d, double* e, const double vl,
72         const double vu, const fortran_int_t il, const fortran_int_t iu,
73         const double abstol, fortran_int_t& m, double* w, double* z,
74         const fortran_int_t ldz, double* work, fortran_int_t* iwork,
75         fortran_int_t* ifail ) {
76     fortran_int_t info(0);
77     LAPACK_DSTEVX( &jobz, &range, &n, d, e, &vl, &vu, &il, &iu, &abstol, &m,
78             w, z, &ldz, work, iwork, ifail, &info );
79     return info;
80 }
81 
82 } // namespace detail
83 
84 //
85 // Value-type based template class. Use this class if you need a type
86 // for dispatching to stevx.
87 //
88 template< typename Value >
89 struct stevx_impl {
90 
91     typedef Value value_type;
92     typedef typename remove_imaginary< Value >::type real_type;
93 
94     //
95     // Static member function for user-defined workspaces, that
96     // * Deduces the required arguments for dispatching to LAPACK, and
97     // * Asserts that most arguments make sense.
98     //
99     template< typename VectorD, typename VectorE, typename VectorW,
100             typename MatrixZ, typename VectorIFAIL, typename WORK,
101             typename IWORK >
invokeboost::numeric::bindings::lapack::stevx_impl102     static std::ptrdiff_t invoke( const char jobz, const char range,
103             const fortran_int_t n, VectorD& d, VectorE& e,
104             const real_type vl, const real_type vu,
105             const fortran_int_t il, const fortran_int_t iu,
106             const real_type abstol, fortran_int_t& m, VectorW& w,
107             MatrixZ& z, VectorIFAIL& ifail, detail::workspace2< WORK,
108             IWORK > work ) {
109         namespace bindings = ::boost::numeric::bindings;
110         BOOST_STATIC_ASSERT( (bindings::is_column_major< MatrixZ >::value) );
111         BOOST_STATIC_ASSERT( (boost::is_same< typename remove_const<
112                 typename bindings::value_type< VectorD >::type >::type,
113                 typename remove_const< typename bindings::value_type<
114                 VectorE >::type >::type >::value) );
115         BOOST_STATIC_ASSERT( (boost::is_same< typename remove_const<
116                 typename bindings::value_type< VectorD >::type >::type,
117                 typename remove_const< typename bindings::value_type<
118                 VectorW >::type >::type >::value) );
119         BOOST_STATIC_ASSERT( (boost::is_same< typename remove_const<
120                 typename bindings::value_type< VectorD >::type >::type,
121                 typename remove_const< typename bindings::value_type<
122                 MatrixZ >::type >::type >::value) );
123         BOOST_STATIC_ASSERT( (bindings::is_mutable< VectorD >::value) );
124         BOOST_STATIC_ASSERT( (bindings::is_mutable< VectorE >::value) );
125         BOOST_STATIC_ASSERT( (bindings::is_mutable< VectorW >::value) );
126         BOOST_STATIC_ASSERT( (bindings::is_mutable< MatrixZ >::value) );
127         BOOST_STATIC_ASSERT( (bindings::is_mutable< VectorIFAIL >::value) );
128         BOOST_ASSERT( bindings::size(d) >= n );
129         BOOST_ASSERT( bindings::size(e) >= std::max< std::ptrdiff_t >(1,n-1) );
130         BOOST_ASSERT( bindings::size(w) >= n );
131         BOOST_ASSERT( bindings::size(work.select(fortran_int_t())) >=
132                 min_size_iwork( n ));
133         BOOST_ASSERT( bindings::size(work.select(real_type())) >=
134                 min_size_work( n ));
135         BOOST_ASSERT( bindings::size_minor(z) == 1 ||
136                 bindings::stride_minor(z) == 1 );
137         BOOST_ASSERT( jobz == 'N' || jobz == 'V' );
138         BOOST_ASSERT( n >= 0 );
139         BOOST_ASSERT( range == 'A' || range == 'V' || range == 'I' );
140         return detail::stevx( jobz, range, n, bindings::begin_value(d),
141                 bindings::begin_value(e), vl, vu, il, iu, abstol, m,
142                 bindings::begin_value(w), bindings::begin_value(z),
143                 bindings::stride_major(z),
144                 bindings::begin_value(work.select(real_type())),
145                 bindings::begin_value(work.select(fortran_int_t())),
146                 bindings::begin_value(ifail) );
147     }
148 
149     //
150     // Static member function that
151     // * Figures out the minimal workspace requirements, and passes
152     //   the results to the user-defined workspace overload of the
153     //   invoke static member function
154     // * Enables the unblocked algorithm (BLAS level 2)
155     //
156     template< typename VectorD, typename VectorE, typename VectorW,
157             typename MatrixZ, typename VectorIFAIL >
invokeboost::numeric::bindings::lapack::stevx_impl158     static std::ptrdiff_t invoke( const char jobz, const char range,
159             const fortran_int_t n, VectorD& d, VectorE& e,
160             const real_type vl, const real_type vu,
161             const fortran_int_t il, const fortran_int_t iu,
162             const real_type abstol, fortran_int_t& m, VectorW& w,
163             MatrixZ& z, VectorIFAIL& ifail, minimal_workspace ) {
164         namespace bindings = ::boost::numeric::bindings;
165         bindings::detail::array< real_type > tmp_work( min_size_work( n ) );
166         bindings::detail::array< fortran_int_t > tmp_iwork(
167                 min_size_iwork( n ) );
168         return invoke( jobz, range, n, d, e, vl, vu, il, iu, abstol, m, w, z,
169                 ifail, workspace( tmp_work, tmp_iwork ) );
170     }
171 
172     //
173     // Static member function that
174     // * Figures out the optimal workspace requirements, and passes
175     //   the results to the user-defined workspace overload of the
176     //   invoke static member
177     // * Enables the blocked algorithm (BLAS level 3)
178     //
179     template< typename VectorD, typename VectorE, typename VectorW,
180             typename MatrixZ, typename VectorIFAIL >
invokeboost::numeric::bindings::lapack::stevx_impl181     static std::ptrdiff_t invoke( const char jobz, const char range,
182             const fortran_int_t n, VectorD& d, VectorE& e,
183             const real_type vl, const real_type vu,
184             const fortran_int_t il, const fortran_int_t iu,
185             const real_type abstol, fortran_int_t& m, VectorW& w,
186             MatrixZ& z, VectorIFAIL& ifail, optimal_workspace ) {
187         namespace bindings = ::boost::numeric::bindings;
188         return invoke( jobz, range, n, d, e, vl, vu, il, iu, abstol, m, w, z,
189                 ifail, minimal_workspace() );
190     }
191 
192     //
193     // Static member function that returns the minimum size of
194     // workspace-array work.
195     //
min_size_workboost::numeric::bindings::lapack::stevx_impl196     static std::ptrdiff_t min_size_work( const std::ptrdiff_t n ) {
197         return 5*n;
198     }
199 
200     //
201     // Static member function that returns the minimum size of
202     // workspace-array iwork.
203     //
min_size_iworkboost::numeric::bindings::lapack::stevx_impl204     static std::ptrdiff_t min_size_iwork( const std::ptrdiff_t n ) {
205         return 5*n;
206     }
207 };
208 
209 
210 //
211 // Functions for direct use. These functions are overloaded for temporaries,
212 // so that wrapped types can still be passed and used for write-access. In
213 // addition, if applicable, they are overloaded for user-defined workspaces.
214 // Calls to these functions are passed to the stevx_impl classes. In the
215 // documentation, most overloads are collapsed to avoid a large number of
216 // prototypes which are very similar.
217 //
218 
219 //
220 // Overloaded function for stevx. Its overload differs for
221 // * User-defined workspace
222 //
223 template< typename VectorD, typename VectorE, typename VectorW,
224         typename MatrixZ, typename VectorIFAIL, typename Workspace >
225 inline typename boost::enable_if< detail::is_workspace< Workspace >,
226         std::ptrdiff_t >::type
stevx(const char jobz,const char range,const fortran_int_t n,VectorD & d,VectorE & e,const typename remove_imaginary<typename bindings::value_type<VectorD>::type>::type vl,const typename remove_imaginary<typename bindings::value_type<VectorD>::type>::type vu,const fortran_int_t il,const fortran_int_t iu,const typename remove_imaginary<typename bindings::value_type<VectorD>::type>::type abstol,fortran_int_t & m,VectorW & w,MatrixZ & z,VectorIFAIL & ifail,Workspace work)227 stevx( const char jobz, const char range, const fortran_int_t n,
228         VectorD& d, VectorE& e, const typename remove_imaginary<
229         typename bindings::value_type< VectorD >::type >::type vl,
230         const typename remove_imaginary< typename bindings::value_type<
231         VectorD >::type >::type vu, const fortran_int_t il,
232         const fortran_int_t iu, const typename remove_imaginary<
233         typename bindings::value_type< VectorD >::type >::type abstol,
234         fortran_int_t& m, VectorW& w, MatrixZ& z, VectorIFAIL& ifail,
235         Workspace work ) {
236     return stevx_impl< typename bindings::value_type<
237             VectorD >::type >::invoke( jobz, range, n, d, e, vl, vu, il, iu,
238             abstol, m, w, z, ifail, work );
239 }
240 
241 //
242 // Overloaded function for stevx. Its overload differs for
243 // * Default workspace-type (optimal)
244 //
245 template< typename VectorD, typename VectorE, typename VectorW,
246         typename MatrixZ, typename VectorIFAIL >
247 inline typename boost::disable_if< detail::is_workspace< VectorIFAIL >,
248         std::ptrdiff_t >::type
stevx(const char jobz,const char range,const fortran_int_t n,VectorD & d,VectorE & e,const typename remove_imaginary<typename bindings::value_type<VectorD>::type>::type vl,const typename remove_imaginary<typename bindings::value_type<VectorD>::type>::type vu,const fortran_int_t il,const fortran_int_t iu,const typename remove_imaginary<typename bindings::value_type<VectorD>::type>::type abstol,fortran_int_t & m,VectorW & w,MatrixZ & z,VectorIFAIL & ifail)249 stevx( const char jobz, const char range, const fortran_int_t n,
250         VectorD& d, VectorE& e, const typename remove_imaginary<
251         typename bindings::value_type< VectorD >::type >::type vl,
252         const typename remove_imaginary< typename bindings::value_type<
253         VectorD >::type >::type vu, const fortran_int_t il,
254         const fortran_int_t iu, const typename remove_imaginary<
255         typename bindings::value_type< VectorD >::type >::type abstol,
256         fortran_int_t& m, VectorW& w, MatrixZ& z, VectorIFAIL& ifail ) {
257     return stevx_impl< typename bindings::value_type<
258             VectorD >::type >::invoke( jobz, range, n, d, e, vl, vu, il, iu,
259             abstol, m, w, z, ifail, optimal_workspace() );
260 }
261 
262 } // namespace lapack
263 } // namespace bindings
264 } // namespace numeric
265 } // namespace boost
266 
267 #endif
268