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_SPEV_HPP
15 #define BOOST_NUMERIC_BINDINGS_LAPACK_DRIVER_SPEV_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/uplo_tag.hpp>
27 #include <boost/numeric/bindings/value_type.hpp>
28 #include <boost/static_assert.hpp>
29 #include <boost/type_traits/is_same.hpp>
30 #include <boost/type_traits/remove_const.hpp>
31 
32 //
33 // The LAPACK-backend for spev is the netlib-compatible backend.
34 //
35 #include <boost/numeric/bindings/lapack/detail/lapack.h>
36 #include <boost/numeric/bindings/lapack/detail/lapack_option.hpp>
37 
38 namespace boost {
39 namespace numeric {
40 namespace bindings {
41 namespace lapack {
42 
43 //
44 // The detail namespace contains value-type-overloaded functions that
45 // dispatch to the appropriate back-end LAPACK-routine.
46 //
47 namespace detail {
48 
49 //
50 // Overloaded function for dispatching to
51 // * netlib-compatible LAPACK backend (the default), and
52 // * float value-type.
53 //
54 template< typename UpLo >
spev(const char jobz,const UpLo,const fortran_int_t n,float * ap,float * w,float * z,const fortran_int_t ldz,float * work)55 inline std::ptrdiff_t spev( const char jobz, const UpLo, const fortran_int_t n,
56         float* ap, float* w, float* z, const fortran_int_t ldz, float* work ) {
57     fortran_int_t info(0);
58     LAPACK_SSPEV( &jobz, &lapack_option< UpLo >::value, &n, ap, w, z, &ldz,
59             work, &info );
60     return info;
61 }
62 
63 //
64 // Overloaded function for dispatching to
65 // * netlib-compatible LAPACK backend (the default), and
66 // * double value-type.
67 //
68 template< typename UpLo >
spev(const char jobz,const UpLo,const fortran_int_t n,double * ap,double * w,double * z,const fortran_int_t ldz,double * work)69 inline std::ptrdiff_t spev( const char jobz, const UpLo, const fortran_int_t n,
70         double* ap, double* w, double* z, const fortran_int_t ldz,
71         double* work ) {
72     fortran_int_t info(0);
73     LAPACK_DSPEV( &jobz, &lapack_option< UpLo >::value, &n, ap, w, z, &ldz,
74             work, &info );
75     return info;
76 }
77 
78 } // namespace detail
79 
80 //
81 // Value-type based template class. Use this class if you need a type
82 // for dispatching to spev.
83 //
84 template< typename Value >
85 struct spev_impl {
86 
87     typedef Value value_type;
88     typedef typename remove_imaginary< Value >::type real_type;
89 
90     //
91     // Static member function for user-defined workspaces, that
92     // * Deduces the required arguments for dispatching to LAPACK, and
93     // * Asserts that most arguments make sense.
94     //
95     template< typename MatrixAP, typename VectorW, typename MatrixZ,
96             typename WORK >
invokeboost::numeric::bindings::lapack::spev_impl97     static std::ptrdiff_t invoke( const char jobz, MatrixAP& ap, VectorW& w,
98             MatrixZ& z, detail::workspace1< WORK > work ) {
99         namespace bindings = ::boost::numeric::bindings;
100         typedef typename result_of::uplo_tag< MatrixAP >::type uplo;
101         BOOST_STATIC_ASSERT( (bindings::is_column_major< MatrixZ >::value) );
102         BOOST_STATIC_ASSERT( (boost::is_same< typename remove_const<
103                 typename bindings::value_type< MatrixAP >::type >::type,
104                 typename remove_const< typename bindings::value_type<
105                 VectorW >::type >::type >::value) );
106         BOOST_STATIC_ASSERT( (boost::is_same< typename remove_const<
107                 typename bindings::value_type< MatrixAP >::type >::type,
108                 typename remove_const< typename bindings::value_type<
109                 MatrixZ >::type >::type >::value) );
110         BOOST_STATIC_ASSERT( (bindings::is_mutable< MatrixAP >::value) );
111         BOOST_STATIC_ASSERT( (bindings::is_mutable< VectorW >::value) );
112         BOOST_STATIC_ASSERT( (bindings::is_mutable< MatrixZ >::value) );
113         BOOST_ASSERT( bindings::size(work.select(real_type())) >=
114                 min_size_work( bindings::size_column(ap) ));
115         BOOST_ASSERT( bindings::size_column(ap) >= 0 );
116         BOOST_ASSERT( bindings::size_minor(z) == 1 ||
117                 bindings::stride_minor(z) == 1 );
118         BOOST_ASSERT( jobz == 'N' || jobz == 'V' );
119         return detail::spev( jobz, uplo(), bindings::size_column(ap),
120                 bindings::begin_value(ap), bindings::begin_value(w),
121                 bindings::begin_value(z), bindings::stride_major(z),
122                 bindings::begin_value(work.select(real_type())) );
123     }
124 
125     //
126     // Static member function that
127     // * Figures out the minimal workspace requirements, and passes
128     //   the results to the user-defined workspace overload of the
129     //   invoke static member function
130     // * Enables the unblocked algorithm (BLAS level 2)
131     //
132     template< typename MatrixAP, typename VectorW, typename MatrixZ >
invokeboost::numeric::bindings::lapack::spev_impl133     static std::ptrdiff_t invoke( const char jobz, MatrixAP& ap, VectorW& w,
134             MatrixZ& z, minimal_workspace ) {
135         namespace bindings = ::boost::numeric::bindings;
136         typedef typename result_of::uplo_tag< MatrixAP >::type uplo;
137         bindings::detail::array< real_type > tmp_work( min_size_work(
138                 bindings::size_column(ap) ) );
139         return invoke( jobz, ap, w, z, workspace( tmp_work ) );
140     }
141 
142     //
143     // Static member function that
144     // * Figures out the optimal workspace requirements, and passes
145     //   the results to the user-defined workspace overload of the
146     //   invoke static member
147     // * Enables the blocked algorithm (BLAS level 3)
148     //
149     template< typename MatrixAP, typename VectorW, typename MatrixZ >
invokeboost::numeric::bindings::lapack::spev_impl150     static std::ptrdiff_t invoke( const char jobz, MatrixAP& ap, VectorW& w,
151             MatrixZ& z, optimal_workspace ) {
152         namespace bindings = ::boost::numeric::bindings;
153         typedef typename result_of::uplo_tag< MatrixAP >::type uplo;
154         return invoke( jobz, ap, w, z, minimal_workspace() );
155     }
156 
157     //
158     // Static member function that returns the minimum size of
159     // workspace-array work.
160     //
min_size_workboost::numeric::bindings::lapack::spev_impl161     static std::ptrdiff_t min_size_work( const std::ptrdiff_t n ) {
162         return 3*n;
163     }
164 };
165 
166 
167 //
168 // Functions for direct use. These functions are overloaded for temporaries,
169 // so that wrapped types can still be passed and used for write-access. In
170 // addition, if applicable, they are overloaded for user-defined workspaces.
171 // Calls to these functions are passed to the spev_impl classes. In the
172 // documentation, most overloads are collapsed to avoid a large number of
173 // prototypes which are very similar.
174 //
175 
176 //
177 // Overloaded function for spev. Its overload differs for
178 // * User-defined workspace
179 //
180 template< typename MatrixAP, typename VectorW, typename MatrixZ,
181         typename Workspace >
182 inline typename boost::enable_if< detail::is_workspace< Workspace >,
183         std::ptrdiff_t >::type
spev(const char jobz,MatrixAP & ap,VectorW & w,MatrixZ & z,Workspace work)184 spev( const char jobz, MatrixAP& ap, VectorW& w, MatrixZ& z,
185         Workspace work ) {
186     return spev_impl< typename bindings::value_type<
187             MatrixAP >::type >::invoke( jobz, ap, w, z, work );
188 }
189 
190 //
191 // Overloaded function for spev. Its overload differs for
192 // * Default workspace-type (optimal)
193 //
194 template< typename MatrixAP, typename VectorW, typename MatrixZ >
195 inline typename boost::disable_if< detail::is_workspace< MatrixZ >,
196         std::ptrdiff_t >::type
spev(const char jobz,MatrixAP & ap,VectorW & w,MatrixZ & z)197 spev( const char jobz, MatrixAP& ap, VectorW& w, MatrixZ& z ) {
198     return spev_impl< typename bindings::value_type<
199             MatrixAP >::type >::invoke( jobz, ap, w, z, optimal_workspace() );
200 }
201 
202 } // namespace lapack
203 } // namespace bindings
204 } // namespace numeric
205 } // namespace boost
206 
207 #endif
208