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_AUXILIARY_LANSB_HPP
15 #define BOOST_NUMERIC_BINDINGS_LAPACK_AUXILIARY_LANSB_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 lansb 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 >
lansb(const char norm,const UpLo,const fortran_int_t n,const fortran_int_t k,const float * ab,const fortran_int_t ldab,float * work)56 inline std::ptrdiff_t lansb( const char norm, const UpLo,
57         const fortran_int_t n, const fortran_int_t k, const float* ab,
58         const fortran_int_t ldab, float* work ) {
59     fortran_int_t info(0);
60     LAPACK_SLANSB( &norm, &lapack_option< UpLo >::value, &n, &k, ab, &ldab,
61             work );
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 //
70 template< typename UpLo >
lansb(const char norm,const UpLo,const fortran_int_t n,const fortran_int_t k,const double * ab,const fortran_int_t ldab,double * work)71 inline std::ptrdiff_t lansb( const char norm, const UpLo,
72         const fortran_int_t n, const fortran_int_t k, const double* ab,
73         const fortran_int_t ldab, double* work ) {
74     fortran_int_t info(0);
75     LAPACK_DLANSB( &norm, &lapack_option< UpLo >::value, &n, &k, ab, &ldab,
76             work );
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 UpLo >
lansb(const char norm,const UpLo,const fortran_int_t n,const fortran_int_t k,const std::complex<float> * ab,const fortran_int_t ldab,float * work)86 inline std::ptrdiff_t lansb( const char norm, const UpLo,
87         const fortran_int_t n, const fortran_int_t k,
88         const std::complex<float>* ab, const fortran_int_t ldab,
89         float* work ) {
90     fortran_int_t info(0);
91     LAPACK_CLANSB( &norm, &lapack_option< UpLo >::value, &n, &k, ab, &ldab,
92             work );
93     return info;
94 }
95 
96 //
97 // Overloaded function for dispatching to
98 // * netlib-compatible LAPACK backend (the default), and
99 // * complex<double> value-type.
100 //
101 template< typename UpLo >
lansb(const char norm,const UpLo,const fortran_int_t n,const fortran_int_t k,const std::complex<double> * ab,const fortran_int_t ldab,double * work)102 inline std::ptrdiff_t lansb( const char norm, const UpLo,
103         const fortran_int_t n, const fortran_int_t k,
104         const std::complex<double>* ab, const fortran_int_t ldab,
105         double* work ) {
106     fortran_int_t info(0);
107     LAPACK_ZLANSB( &norm, &lapack_option< UpLo >::value, &n, &k, ab, &ldab,
108             work );
109     return info;
110 }
111 
112 } // namespace detail
113 
114 //
115 // Value-type based template class. Use this class if you need a type
116 // for dispatching to lansb.
117 //
118 template< typename Value >
119 struct lansb_impl {
120 
121     typedef Value value_type;
122     typedef typename remove_imaginary< Value >::type real_type;
123 
124     //
125     // Static member function for user-defined workspaces, that
126     // * Deduces the required arguments for dispatching to LAPACK, and
127     // * Asserts that most arguments make sense.
128     //
129     template< typename MatrixAB, typename WORK >
invokeboost::numeric::bindings::lapack::lansb_impl130     static std::ptrdiff_t invoke( const char norm, const MatrixAB& ab,
131             detail::workspace1< WORK > work ) {
132         namespace bindings = ::boost::numeric::bindings;
133         typedef typename result_of::uplo_tag< MatrixAB >::type uplo;
134         BOOST_STATIC_ASSERT( (bindings::is_column_major< MatrixAB >::value) );
135         BOOST_ASSERT( bindings::bandwidth_lower(ab) >= 0 );
136         BOOST_ASSERT( bindings::size(work.select(real_type())) >=
137                 min_size_work( norm, bindings::size_column(ab) ));
138         BOOST_ASSERT( bindings::size_column(ab) >= 0 );
139         BOOST_ASSERT( bindings::size_minor(ab) == 1 ||
140                 bindings::stride_minor(ab) == 1 );
141         BOOST_ASSERT( bindings::stride_major(ab) >=
142                 bindings::bandwidth_lower(ab)+1 );
143         return detail::lansb( norm, uplo(), bindings::size_column(ab),
144                 bindings::bandwidth_lower(ab), bindings::begin_value(ab),
145                 bindings::stride_major(ab),
146                 bindings::begin_value(work.select(real_type())) );
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 MatrixAB >
invokeboost::numeric::bindings::lapack::lansb_impl157     static std::ptrdiff_t invoke( const char norm, const MatrixAB& ab,
158             minimal_workspace ) {
159         namespace bindings = ::boost::numeric::bindings;
160         typedef typename result_of::uplo_tag< MatrixAB >::type uplo;
161         bindings::detail::array< real_type > tmp_work( min_size_work( norm,
162                 bindings::size_column(ab) ) );
163         return invoke( norm, ab, workspace( tmp_work ) );
164     }
165 
166     //
167     // Static member function that
168     // * Figures out the optimal workspace requirements, and passes
169     //   the results to the user-defined workspace overload of the
170     //   invoke static member
171     // * Enables the blocked algorithm (BLAS level 3)
172     //
173     template< typename MatrixAB >
invokeboost::numeric::bindings::lapack::lansb_impl174     static std::ptrdiff_t invoke( const char norm, const MatrixAB& ab,
175             optimal_workspace ) {
176         namespace bindings = ::boost::numeric::bindings;
177         typedef typename result_of::uplo_tag< MatrixAB >::type uplo;
178         return invoke( norm, ab, minimal_workspace() );
179     }
180 
181     //
182     // Static member function that returns the minimum size of
183     // workspace-array work.
184     //
min_size_workboost::numeric::bindings::lapack::lansb_impl185     static std::ptrdiff_t min_size_work( const char norm,
186             const std::ptrdiff_t n ) {
187         if ( norm == 'I' || norm == '1' || norm == 'O' )
188             return std::max< std::ptrdiff_t >( 1, n );
189         else
190             return 1;
191     }
192 };
193 
194 
195 //
196 // Functions for direct use. These functions are overloaded for temporaries,
197 // so that wrapped types can still be passed and used for write-access. In
198 // addition, if applicable, they are overloaded for user-defined workspaces.
199 // Calls to these functions are passed to the lansb_impl classes. In the
200 // documentation, most overloads are collapsed to avoid a large number of
201 // prototypes which are very similar.
202 //
203 
204 //
205 // Overloaded function for lansb. Its overload differs for
206 // * User-defined workspace
207 //
208 template< typename MatrixAB, typename Workspace >
209 inline typename boost::enable_if< detail::is_workspace< Workspace >,
210         std::ptrdiff_t >::type
lansb(const char norm,const MatrixAB & ab,Workspace work)211 lansb( const char norm, const MatrixAB& ab, Workspace work ) {
212     return lansb_impl< typename bindings::value_type<
213             MatrixAB >::type >::invoke( norm, ab, work );
214 }
215 
216 //
217 // Overloaded function for lansb. Its overload differs for
218 // * Default workspace-type (optimal)
219 //
220 template< typename MatrixAB >
221 inline typename boost::disable_if< detail::is_workspace< MatrixAB >,
222         std::ptrdiff_t >::type
lansb(const char norm,const MatrixAB & ab)223 lansb( const char norm, const MatrixAB& ab ) {
224     return lansb_impl< typename bindings::value_type<
225             MatrixAB >::type >::invoke( norm, ab, optimal_workspace() );
226 }
227 
228 } // namespace lapack
229 } // namespace bindings
230 } // namespace numeric
231 } // namespace boost
232 
233 #endif
234