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 
11 #ifndef BOOST_NUMERIC_BINDINGS_BLAS_LEVEL1_SET_HPP
12 #define BOOST_NUMERIC_BINDINGS_BLAS_LEVEL1_SET_HPP
13 
14 #include <boost/assert.hpp>
15 #include <boost/numeric/bindings/begin.hpp>
16 #include <boost/numeric/bindings/end.hpp>
17 #include <boost/numeric/bindings/is_mutable.hpp>
18 #include <boost/numeric/bindings/value_type.hpp>
19 #include <boost/static_assert.hpp>
20 
21 namespace boost {
22 namespace numeric {
23 namespace bindings {
24 namespace blas {
25 
26 //
27 // set is an extension, not part of the BLAS API.
28 //
29 // TODO implement ATLAS backend call(s)
30 //
31 // Functions for direct use. These functions are overloaded for temporaries,
32 // so that wrapped types can still be passed and used for write-access.
33 //
34 
35 //
36 // Overloaded function for set. Its overload differs for
37 // * VectorX&
38 //
39 template< typename VectorX >
40 inline void
set(const typename bindings::value_type<VectorX>::type a,VectorX & x)41 set( const typename bindings::value_type< VectorX >::type a, VectorX& x ) {
42     BOOST_STATIC_ASSERT( (bindings::is_mutable< VectorX >::value) );
43     std::fill( bindings::begin(x), bindings::end(x), a );
44 }
45 
46 //
47 // Overloaded function for set. Its overload differs for
48 // * const VectorX&
49 //
50 template< typename VectorX >
51 inline void
set(const typename bindings::value_type<const VectorX>::type a,const VectorX & x)52 set( const typename bindings::value_type< const VectorX >::type a,  const VectorX& x ) {
53     BOOST_STATIC_ASSERT( (bindings::is_mutable< const VectorX >::value) );
54     std::fill( bindings::begin(x), bindings::end(x), a );
55 }
56 
57 } // namespace blas
58 } // namespace bindings
59 } // namespace numeric
60 } // namespace boost
61 
62 #endif
63