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_LANGB_HPP
15 #define BOOST_NUMERIC_BINDINGS_LAPACK_AUXILIARY_LANGB_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/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 langb 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 //
langb(const char norm,const fortran_int_t n,const fortran_int_t kl,const fortran_int_t ku,const float * ab,const fortran_int_t ldab,float * work)54 inline std::ptrdiff_t langb( const char norm, const fortran_int_t n,
55         const fortran_int_t kl, const fortran_int_t ku, const float* ab,
56         const fortran_int_t ldab, float* work ) {
57     fortran_int_t info(0);
58     LAPACK_SLANGB( &norm, &n, &kl, &ku, ab, &ldab, work );
59     return info;
60 }
61 
62 //
63 // Overloaded function for dispatching to
64 // * netlib-compatible LAPACK backend (the default), and
65 // * double value-type.
66 //
langb(const char norm,const fortran_int_t n,const fortran_int_t kl,const fortran_int_t ku,const double * ab,const fortran_int_t ldab,double * work)67 inline std::ptrdiff_t langb( const char norm, const fortran_int_t n,
68         const fortran_int_t kl, const fortran_int_t ku, const double* ab,
69         const fortran_int_t ldab, double* work ) {
70     fortran_int_t info(0);
71     LAPACK_DLANGB( &norm, &n, &kl, &ku, ab, &ldab, work );
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 //
langb(const char norm,const fortran_int_t n,const fortran_int_t kl,const fortran_int_t ku,const std::complex<float> * ab,const fortran_int_t ldab,float * work)80 inline std::ptrdiff_t langb( const char norm, const fortran_int_t n,
81         const fortran_int_t kl, const fortran_int_t ku,
82         const std::complex<float>* ab, const fortran_int_t ldab,
83         float* work ) {
84     fortran_int_t info(0);
85     LAPACK_CLANGB( &norm, &n, &kl, &ku, ab, &ldab, work );
86     return info;
87 }
88 
89 //
90 // Overloaded function for dispatching to
91 // * netlib-compatible LAPACK backend (the default), and
92 // * complex<double> value-type.
93 //
langb(const char norm,const fortran_int_t n,const fortran_int_t kl,const fortran_int_t ku,const std::complex<double> * ab,const fortran_int_t ldab,double * work)94 inline std::ptrdiff_t langb( const char norm, const fortran_int_t n,
95         const fortran_int_t kl, const fortran_int_t ku,
96         const std::complex<double>* ab, const fortran_int_t ldab,
97         double* work ) {
98     fortran_int_t info(0);
99     LAPACK_ZLANGB( &norm, &n, &kl, &ku, ab, &ldab, work );
100     return info;
101 }
102 
103 } // namespace detail
104 
105 //
106 // Value-type based template class. Use this class if you need a type
107 // for dispatching to langb.
108 //
109 template< typename Value >
110 struct langb_impl {
111 
112     typedef Value value_type;
113     typedef typename remove_imaginary< Value >::type real_type;
114 
115     //
116     // Static member function for user-defined workspaces, that
117     // * Deduces the required arguments for dispatching to LAPACK, and
118     // * Asserts that most arguments make sense.
119     //
120     template< typename MatrixAB, typename WORK >
invokeboost::numeric::bindings::lapack::langb_impl121     static std::ptrdiff_t invoke( const char norm, const MatrixAB& ab,
122             detail::workspace1< WORK > work ) {
123         namespace bindings = ::boost::numeric::bindings;
124         BOOST_STATIC_ASSERT( (bindings::is_column_major< MatrixAB >::value) );
125         BOOST_ASSERT( bindings::bandwidth_lower(ab) >= 0 );
126         BOOST_ASSERT( bindings::bandwidth_upper(ab) >= 0 );
127         BOOST_ASSERT( bindings::size(work.select(real_type())) >=
128                 min_size_work( norm, bindings::size_column(ab) ));
129         BOOST_ASSERT( bindings::size_column(ab) >= 0 );
130         BOOST_ASSERT( bindings::size_minor(ab) == 1 ||
131                 bindings::stride_minor(ab) == 1 );
132         BOOST_ASSERT( bindings::stride_major(ab) >=
133                 bindings::bandwidth_lower(ab)+bindings::bandwidth_upper(ab)+
134                 1 );
135         return detail::langb( norm, bindings::size_column(ab),
136                 bindings::bandwidth_lower(ab), bindings::bandwidth_upper(ab),
137                 bindings::begin_value(ab), bindings::stride_major(ab),
138                 bindings::begin_value(work.select(real_type())) );
139     }
140 
141     //
142     // Static member function that
143     // * Figures out the minimal workspace requirements, and passes
144     //   the results to the user-defined workspace overload of the
145     //   invoke static member function
146     // * Enables the unblocked algorithm (BLAS level 2)
147     //
148     template< typename MatrixAB >
invokeboost::numeric::bindings::lapack::langb_impl149     static std::ptrdiff_t invoke( const char norm, const MatrixAB& ab,
150             minimal_workspace ) {
151         namespace bindings = ::boost::numeric::bindings;
152         bindings::detail::array< real_type > tmp_work( min_size_work( norm,
153                 bindings::size_column(ab) ) );
154         return invoke( norm, ab, workspace( tmp_work ) );
155     }
156 
157     //
158     // Static member function that
159     // * Figures out the optimal workspace requirements, and passes
160     //   the results to the user-defined workspace overload of the
161     //   invoke static member
162     // * Enables the blocked algorithm (BLAS level 3)
163     //
164     template< typename MatrixAB >
invokeboost::numeric::bindings::lapack::langb_impl165     static std::ptrdiff_t invoke( const char norm, const MatrixAB& ab,
166             optimal_workspace ) {
167         namespace bindings = ::boost::numeric::bindings;
168         return invoke( norm, ab, minimal_workspace() );
169     }
170 
171     //
172     // Static member function that returns the minimum size of
173     // workspace-array work.
174     //
min_size_workboost::numeric::bindings::lapack::langb_impl175     static std::ptrdiff_t min_size_work( const char norm,
176             const std::ptrdiff_t n ) {
177         if ( norm == 'I' )
178             return std::max< std::ptrdiff_t >( 1, n );
179         else
180             return 1;
181     }
182 };
183 
184 
185 //
186 // Functions for direct use. These functions are overloaded for temporaries,
187 // so that wrapped types can still be passed and used for write-access. In
188 // addition, if applicable, they are overloaded for user-defined workspaces.
189 // Calls to these functions are passed to the langb_impl classes. In the
190 // documentation, most overloads are collapsed to avoid a large number of
191 // prototypes which are very similar.
192 //
193 
194 //
195 // Overloaded function for langb. Its overload differs for
196 // * User-defined workspace
197 //
198 template< typename MatrixAB, typename Workspace >
199 inline typename boost::enable_if< detail::is_workspace< Workspace >,
200         std::ptrdiff_t >::type
langb(const char norm,const MatrixAB & ab,Workspace work)201 langb( const char norm, const MatrixAB& ab, Workspace work ) {
202     return langb_impl< typename bindings::value_type<
203             MatrixAB >::type >::invoke( norm, ab, work );
204 }
205 
206 //
207 // Overloaded function for langb. Its overload differs for
208 // * Default workspace-type (optimal)
209 //
210 template< typename MatrixAB >
211 inline typename boost::disable_if< detail::is_workspace< MatrixAB >,
212         std::ptrdiff_t >::type
langb(const char norm,const MatrixAB & ab)213 langb( const char norm, const MatrixAB& ab ) {
214     return langb_impl< typename bindings::value_type<
215             MatrixAB >::type >::invoke( norm, ab, optimal_workspace() );
216 }
217 
218 } // namespace lapack
219 } // namespace bindings
220 } // namespace numeric
221 } // namespace boost
222 
223 #endif
224