Initial commit.

This commit is contained in:
2018-12-06 16:01:56 +01:00
parent 10867b60c2
commit 18eb3f6047
1011 changed files with 345688 additions and 10 deletions

View File

@@ -0,0 +1,230 @@
//
// Copyright (c) 2002--2010
// Toon Knapen, Karl Meerbergen, Kresimir Fresl,
// Thomas Klimpel and Rutger ter Borg
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// THIS FILE IS AUTOMATICALLY GENERATED
// PLEASE DO NOT EDIT!
//
#ifndef BOOST_NUMERIC_BINDINGS_BLAS_LEVEL1_ASUM_HPP
#define BOOST_NUMERIC_BINDINGS_BLAS_LEVEL1_ASUM_HPP
#include <boost/assert.hpp>
#include <boost/numeric/bindings/begin.hpp>
#include <boost/numeric/bindings/has_linear_array.hpp>
#include <boost/numeric/bindings/is_mutable.hpp>
#include <boost/numeric/bindings/remove_imaginary.hpp>
#include <boost/numeric/bindings/size.hpp>
#include <boost/numeric/bindings/stride.hpp>
#include <boost/numeric/bindings/value_type.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/remove_const.hpp>
//
// The BLAS-backend is selected by defining a pre-processor variable,
// which can be one of
// * for CBLAS, define BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
// * for CUBLAS, define BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
// * netlib-compatible BLAS is the default
//
#if defined BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
#include <boost/numeric/bindings/blas/detail/cblas.h>
#include <boost/numeric/bindings/blas/detail/cblas_option.hpp>
#elif defined BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
#include <boost/numeric/bindings/blas/detail/cublas.h>
#include <boost/numeric/bindings/blas/detail/blas_option.hpp>
#else
#include <boost/numeric/bindings/blas/detail/blas.h>
#include <boost/numeric/bindings/blas/detail/blas_option.hpp>
#endif
namespace boost {
namespace numeric {
namespace bindings {
namespace blas {
//
// The detail namespace contains value-type-overloaded functions that
// dispatch to the appropriate back-end BLAS-routine.
//
namespace detail {
#if defined BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * float value-type.
//
inline float asum( const int n, const float* x, const int incx ) {
return cblas_sasum( n, x, incx );
}
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * double value-type.
//
inline double asum( const int n, const double* x, const int incx ) {
return cblas_dasum( n, x, incx );
}
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * complex<float> value-type.
//
inline float asum( const int n, const std::complex<float>* x,
const int incx ) {
return cblas_scasum( n, x, incx );
}
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * complex<double> value-type.
//
inline double asum( const int n, const std::complex<double>* x,
const int incx ) {
return cblas_dzasum( n, x, incx );
}
#elif defined BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * float value-type.
//
inline float asum( const int n, const float* x, const int incx ) {
return cublasSasum( n, x, incx );
}
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * double value-type.
//
inline double asum( const int n, const double* x, const int incx ) {
return cublasDasum( n, x, incx );
}
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * complex<float> value-type.
//
inline float asum( const int n, const std::complex<float>* x,
const int incx ) {
return cublasScasum( n, x, incx );
}
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * complex<double> value-type.
//
inline double asum( const int n, const std::complex<double>* x,
const int incx ) {
return cublasDzasum( n, x, incx );
}
#else
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * float value-type.
//
inline float asum( const fortran_int_t n, const float* x,
const fortran_int_t incx ) {
return BLAS_SASUM( &n, x, &incx );
}
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * double value-type.
//
inline double asum( const fortran_int_t n, const double* x,
const fortran_int_t incx ) {
return BLAS_DASUM( &n, x, &incx );
}
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * complex<float> value-type.
//
inline float asum( const fortran_int_t n, const std::complex<float>* x,
const fortran_int_t incx ) {
return BLAS_SCASUM( &n, x, &incx );
}
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * complex<double> value-type.
//
inline double asum( const fortran_int_t n, const std::complex<double>* x,
const fortran_int_t incx ) {
return BLAS_DZASUM( &n, x, &incx );
}
#endif
} // namespace detail
//
// Value-type based template class. Use this class if you need a type
// for dispatching to asum.
//
template< typename Value >
struct asum_impl {
typedef Value value_type;
typedef typename remove_imaginary< Value >::type real_type;
typedef real_type result_type;
//
// Static member function that
// * Deduces the required arguments for dispatching to BLAS, and
// * Asserts that most arguments make sense.
//
template< typename VectorX >
static result_type invoke( const VectorX& x ) {
namespace bindings = ::boost::numeric::bindings;
BOOST_STATIC_ASSERT( (bindings::has_linear_array< VectorX >::value) );
return detail::asum( bindings::size(x),
bindings::begin_value(x), bindings::stride(x) );
}
};
//
// Functions for direct use. These functions are overloaded for temporaries,
// so that wrapped types can still be passed and used for write-access. Calls
// to these functions are passed to the asum_impl classes. In the
// documentation, the const-overloads are collapsed to avoid a large number of
// prototypes which are very similar.
//
//
// Overloaded function for asum. Its overload differs for
//
template< typename VectorX >
inline typename asum_impl< typename bindings::value_type<
VectorX >::type >::result_type
asum( const VectorX& x ) {
return asum_impl< typename bindings::value_type<
VectorX >::type >::invoke( x );
}
} // namespace blas
} // namespace bindings
} // namespace numeric
} // namespace boost
#endif

View File

@@ -0,0 +1,249 @@
//
// Copyright (c) 2002--2010
// Toon Knapen, Karl Meerbergen, Kresimir Fresl,
// Thomas Klimpel and Rutger ter Borg
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// THIS FILE IS AUTOMATICALLY GENERATED
// PLEASE DO NOT EDIT!
//
#ifndef BOOST_NUMERIC_BINDINGS_BLAS_LEVEL1_AXPY_HPP
#define BOOST_NUMERIC_BINDINGS_BLAS_LEVEL1_AXPY_HPP
#include <boost/assert.hpp>
#include <boost/numeric/bindings/begin.hpp>
#include <boost/numeric/bindings/has_linear_array.hpp>
#include <boost/numeric/bindings/is_mutable.hpp>
#include <boost/numeric/bindings/remove_imaginary.hpp>
#include <boost/numeric/bindings/size.hpp>
#include <boost/numeric/bindings/stride.hpp>
#include <boost/numeric/bindings/value_type.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/remove_const.hpp>
//
// The BLAS-backend is selected by defining a pre-processor variable,
// which can be one of
// * for CBLAS, define BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
// * for CUBLAS, define BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
// * netlib-compatible BLAS is the default
//
#if defined BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
#include <boost/numeric/bindings/blas/detail/cblas.h>
#include <boost/numeric/bindings/blas/detail/cblas_option.hpp>
#elif defined BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
#include <boost/numeric/bindings/blas/detail/cublas.h>
#include <boost/numeric/bindings/blas/detail/blas_option.hpp>
#else
#include <boost/numeric/bindings/blas/detail/blas.h>
#include <boost/numeric/bindings/blas/detail/blas_option.hpp>
#endif
namespace boost {
namespace numeric {
namespace bindings {
namespace blas {
//
// The detail namespace contains value-type-overloaded functions that
// dispatch to the appropriate back-end BLAS-routine.
//
namespace detail {
#if defined BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * float value-type.
//
inline void axpy( const int n, const float a, const float* x, const int incx,
float* y, const int incy ) {
cblas_saxpy( n, a, x, incx, y, incy );
}
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * double value-type.
//
inline void axpy( const int n, const double a, const double* x,
const int incx, double* y, const int incy ) {
cblas_daxpy( n, a, x, incx, y, incy );
}
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * complex<float> value-type.
//
inline void axpy( const int n, const std::complex<float> a,
const std::complex<float>* x, const int incx, std::complex<float>* y,
const int incy ) {
cblas_caxpy( n, &a, x, incx, y, incy );
}
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * complex<double> value-type.
//
inline void axpy( const int n, const std::complex<double> a,
const std::complex<double>* x, const int incx,
std::complex<double>* y, const int incy ) {
cblas_zaxpy( n, &a, x, incx, y, incy );
}
#elif defined BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * float value-type.
//
inline void axpy( const int n, const float a, const float* x, const int incx,
float* y, const int incy ) {
cublasSaxpy( n, a, x, incx, y, incy );
}
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * double value-type.
//
inline void axpy( const int n, const double a, const double* x,
const int incx, double* y, const int incy ) {
cublasDaxpy( n, a, x, incx, y, incy );
}
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * complex<float> value-type.
//
inline void axpy( const int n, const std::complex<float> a,
const std::complex<float>* x, const int incx, std::complex<float>* y,
const int incy ) {
cublasCaxpy( n, a, x, incx, y, incy );
}
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * complex<double> value-type.
//
inline void axpy( const int n, const std::complex<double> a,
const std::complex<double>* x, const int incx,
std::complex<double>* y, const int incy ) {
cublasZaxpy( n, a, x, incx, y, incy );
}
#else
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * float value-type.
//
inline void axpy( const fortran_int_t n, const float a, const float* x,
const fortran_int_t incx, float* y, const fortran_int_t incy ) {
BLAS_SAXPY( &n, &a, x, &incx, y, &incy );
}
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * double value-type.
//
inline void axpy( const fortran_int_t n, const double a, const double* x,
const fortran_int_t incx, double* y, const fortran_int_t incy ) {
BLAS_DAXPY( &n, &a, x, &incx, y, &incy );
}
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * complex<float> value-type.
//
inline void axpy( const fortran_int_t n, const std::complex<float> a,
const std::complex<float>* x, const fortran_int_t incx,
std::complex<float>* y, const fortran_int_t incy ) {
BLAS_CAXPY( &n, &a, x, &incx, y, &incy );
}
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * complex<double> value-type.
//
inline void axpy( const fortran_int_t n, const std::complex<double> a,
const std::complex<double>* x, const fortran_int_t incx,
std::complex<double>* y, const fortran_int_t incy ) {
BLAS_ZAXPY( &n, &a, x, &incx, y, &incy );
}
#endif
} // namespace detail
//
// Value-type based template class. Use this class if you need a type
// for dispatching to axpy.
//
template< typename Value >
struct axpy_impl {
typedef Value value_type;
typedef typename remove_imaginary< Value >::type real_type;
typedef void result_type;
//
// Static member function that
// * Deduces the required arguments for dispatching to BLAS, and
// * Asserts that most arguments make sense.
//
template< typename VectorX, typename VectorY >
static result_type invoke( const value_type a, const VectorX& x,
VectorY& y ) {
namespace bindings = ::boost::numeric::bindings;
BOOST_STATIC_ASSERT( (is_same< typename remove_const<
typename bindings::value_type< VectorX >::type >::type,
typename remove_const< typename bindings::value_type<
VectorY >::type >::type >::value) );
BOOST_STATIC_ASSERT( (bindings::has_linear_array< VectorX >::value) );
BOOST_STATIC_ASSERT( (bindings::has_linear_array< VectorY >::value) );
BOOST_STATIC_ASSERT( (bindings::is_mutable< VectorY >::value) );
detail::axpy( bindings::size(x), a, bindings::begin_value(x),
bindings::stride(x), bindings::begin_value(y),
bindings::stride(y) );
}
};
//
// Functions for direct use. These functions are overloaded for temporaries,
// so that wrapped types can still be passed and used for write-access. Calls
// to these functions are passed to the axpy_impl classes. In the
// documentation, the const-overloads are collapsed to avoid a large number of
// prototypes which are very similar.
//
//
// Overloaded function for axpy. Its overload differs for
//
template< typename VectorX, typename VectorY >
inline typename axpy_impl< typename bindings::value_type<
VectorX >::type >::result_type
axpy( const typename bindings::value_type< VectorX >::type a,
const VectorX& x, VectorY& y ) {
axpy_impl< typename bindings::value_type<
VectorX >::type >::invoke( a, x, y );
}
} // namespace blas
} // namespace bindings
} // namespace numeric
} // namespace boost
#endif

View File

@@ -0,0 +1,243 @@
//
// Copyright (c) 2002--2010
// Toon Knapen, Karl Meerbergen, Kresimir Fresl,
// Thomas Klimpel and Rutger ter Borg
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// THIS FILE IS AUTOMATICALLY GENERATED
// PLEASE DO NOT EDIT!
//
#ifndef BOOST_NUMERIC_BINDINGS_BLAS_LEVEL1_COPY_HPP
#define BOOST_NUMERIC_BINDINGS_BLAS_LEVEL1_COPY_HPP
#include <boost/assert.hpp>
#include <boost/numeric/bindings/begin.hpp>
#include <boost/numeric/bindings/has_linear_array.hpp>
#include <boost/numeric/bindings/is_mutable.hpp>
#include <boost/numeric/bindings/remove_imaginary.hpp>
#include <boost/numeric/bindings/size.hpp>
#include <boost/numeric/bindings/stride.hpp>
#include <boost/numeric/bindings/value_type.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/remove_const.hpp>
//
// The BLAS-backend is selected by defining a pre-processor variable,
// which can be one of
// * for CBLAS, define BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
// * for CUBLAS, define BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
// * netlib-compatible BLAS is the default
//
#if defined BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
#include <boost/numeric/bindings/blas/detail/cblas.h>
#include <boost/numeric/bindings/blas/detail/cblas_option.hpp>
#elif defined BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
#include <boost/numeric/bindings/blas/detail/cublas.h>
#include <boost/numeric/bindings/blas/detail/blas_option.hpp>
#else
#include <boost/numeric/bindings/blas/detail/blas.h>
#include <boost/numeric/bindings/blas/detail/blas_option.hpp>
#endif
namespace boost {
namespace numeric {
namespace bindings {
namespace blas {
//
// The detail namespace contains value-type-overloaded functions that
// dispatch to the appropriate back-end BLAS-routine.
//
namespace detail {
#if defined BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * float value-type.
//
inline void copy( const int n, const float* x, const int incx, float* y,
const int incy ) {
cblas_scopy( n, x, incx, y, incy );
}
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * double value-type.
//
inline void copy( const int n, const double* x, const int incx, double* y,
const int incy ) {
cblas_dcopy( n, x, incx, y, incy );
}
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * complex<float> value-type.
//
inline void copy( const int n, const std::complex<float>* x, const int incx,
std::complex<float>* y, const int incy ) {
cblas_ccopy( n, x, incx, y, incy );
}
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * complex<double> value-type.
//
inline void copy( const int n, const std::complex<double>* x, const int incx,
std::complex<double>* y, const int incy ) {
cblas_zcopy( n, x, incx, y, incy );
}
#elif defined BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * float value-type.
//
inline void copy( const int n, const float* x, const int incx, float* y,
const int incy ) {
cublasScopy( n, x, incx, y, incy );
}
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * double value-type.
//
inline void copy( const int n, const double* x, const int incx, double* y,
const int incy ) {
cublasDcopy( n, x, incx, y, incy );
}
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * complex<float> value-type.
//
inline void copy( const int n, const std::complex<float>* x, const int incx,
std::complex<float>* y, const int incy ) {
cublasCcopy( n, x, incx, y, incy );
}
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * complex<double> value-type.
//
inline void copy( const int n, const std::complex<double>* x, const int incx,
std::complex<double>* y, const int incy ) {
cublasZcopy( n, x, incx, y, incy );
}
#else
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * float value-type.
//
inline void copy( const fortran_int_t n, const float* x,
const fortran_int_t incx, float* y, const fortran_int_t incy ) {
BLAS_SCOPY( &n, x, &incx, y, &incy );
}
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * double value-type.
//
inline void copy( const fortran_int_t n, const double* x,
const fortran_int_t incx, double* y, const fortran_int_t incy ) {
BLAS_DCOPY( &n, x, &incx, y, &incy );
}
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * complex<float> value-type.
//
inline void copy( const fortran_int_t n, const std::complex<float>* x,
const fortran_int_t incx, std::complex<float>* y,
const fortran_int_t incy ) {
BLAS_CCOPY( &n, x, &incx, y, &incy );
}
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * complex<double> value-type.
//
inline void copy( const fortran_int_t n, const std::complex<double>* x,
const fortran_int_t incx, std::complex<double>* y,
const fortran_int_t incy ) {
BLAS_ZCOPY( &n, x, &incx, y, &incy );
}
#endif
} // namespace detail
//
// Value-type based template class. Use this class if you need a type
// for dispatching to copy.
//
template< typename Value >
struct copy_impl {
typedef Value value_type;
typedef typename remove_imaginary< Value >::type real_type;
typedef void result_type;
//
// Static member function that
// * Deduces the required arguments for dispatching to BLAS, and
// * Asserts that most arguments make sense.
//
template< typename VectorX, typename VectorY >
static result_type invoke( const VectorX& x, VectorY& y ) {
namespace bindings = ::boost::numeric::bindings;
BOOST_STATIC_ASSERT( (is_same< typename remove_const<
typename bindings::value_type< VectorX >::type >::type,
typename remove_const< typename bindings::value_type<
VectorY >::type >::type >::value) );
BOOST_STATIC_ASSERT( (bindings::has_linear_array< VectorX >::value) );
BOOST_STATIC_ASSERT( (bindings::has_linear_array< VectorY >::value) );
BOOST_STATIC_ASSERT( (bindings::is_mutable< VectorY >::value) );
detail::copy( bindings::size(x), bindings::begin_value(x),
bindings::stride(x), bindings::begin_value(y),
bindings::stride(y) );
}
};
//
// Functions for direct use. These functions are overloaded for temporaries,
// so that wrapped types can still be passed and used for write-access. Calls
// to these functions are passed to the copy_impl classes. In the
// documentation, the const-overloads are collapsed to avoid a large number of
// prototypes which are very similar.
//
//
// Overloaded function for copy. Its overload differs for
//
template< typename VectorX, typename VectorY >
inline typename copy_impl< typename bindings::value_type<
VectorX >::type >::result_type
copy( const VectorX& x, VectorY& y ) {
copy_impl< typename bindings::value_type<
VectorX >::type >::invoke( x, y );
}
} // namespace blas
} // namespace bindings
} // namespace numeric
} // namespace boost
#endif

View File

@@ -0,0 +1,246 @@
//
// Copyright (c) 2002--2010
// Toon Knapen, Karl Meerbergen, Kresimir Fresl,
// Thomas Klimpel and Rutger ter Borg
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// THIS FILE IS AUTOMATICALLY GENERATED
// PLEASE DO NOT EDIT!
//
#ifndef BOOST_NUMERIC_BINDINGS_BLAS_LEVEL1_DOT_HPP
#define BOOST_NUMERIC_BINDINGS_BLAS_LEVEL1_DOT_HPP
#include <boost/assert.hpp>
#include <boost/numeric/bindings/begin.hpp>
#include <boost/numeric/bindings/has_linear_array.hpp>
#include <boost/numeric/bindings/is_mutable.hpp>
#include <boost/numeric/bindings/remove_imaginary.hpp>
#include <boost/numeric/bindings/size.hpp>
#include <boost/numeric/bindings/stride.hpp>
#include <boost/numeric/bindings/value_type.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/remove_const.hpp>
//
// The BLAS-backend is selected by defining a pre-processor variable,
// which can be one of
// * for CBLAS, define BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
// * for CUBLAS, define BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
// * netlib-compatible BLAS is the default
//
#if defined BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
#include <boost/numeric/bindings/blas/detail/cblas.h>
#include <boost/numeric/bindings/blas/detail/cblas_option.hpp>
#elif defined BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
#include <boost/numeric/bindings/blas/detail/cublas.h>
#include <boost/numeric/bindings/blas/detail/blas_option.hpp>
#else
#include <boost/numeric/bindings/blas/detail/blas.h>
#include <boost/numeric/bindings/blas/detail/blas_option.hpp>
#endif
namespace boost {
namespace numeric {
namespace bindings {
namespace blas {
//
// The detail namespace contains value-type-overloaded functions that
// dispatch to the appropriate back-end BLAS-routine.
//
namespace detail {
#if defined BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * float value-type.
//
inline float dot( const int n, const float* x, const int incx, const float* y,
const int incy ) {
return cblas_sdot( n, x, incx, y, incy );
}
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * double value-type.
//
inline double dot( const int n, const double* x, const int incx,
const double* y, const int incy ) {
return cblas_ddot( n, x, incx, y, incy );
}
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * complex<float> value-type.
//
inline std::complex<float> dot( const int n, const std::complex<float>* x,
const int incx, const std::complex<float>* y, const int incy ) {
std::complex<float> result;
cblas_cdotu_sub( n, x, incx, y, incy, &result );
return result;
}
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * complex<double> value-type.
//
inline std::complex<double> dot( const int n, const std::complex<double>* x,
const int incx, const std::complex<double>* y, const int incy ) {
std::complex<double> result;
cblas_zdotu_sub( n, x, incx, y, incy, &result );
return result;
}
#elif defined BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * float value-type.
//
inline float dot( const int n, const float* x, const int incx, const float* y,
const int incy ) {
return cublasSdot( n, x, incx, y, incy );
}
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * double value-type.
//
inline double dot( const int n, const double* x, const int incx,
const double* y, const int incy ) {
return cublasDdot( n, x, incx, y, incy );
}
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * complex<float> value-type.
//
inline std::complex<float> dot( const int n, const std::complex<float>* x,
const int incx, const std::complex<float>* y, const int incy ) {
return cublasCdotu( n, x, incx, y, incy );
}
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * complex<double> value-type.
//
inline std::complex<double> dot( const int n, const std::complex<double>* x,
const int incx, const std::complex<double>* y, const int incy ) {
return cublasZdotu( n, x, incx, y, incy );
}
#else
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * float value-type.
//
inline float dot( const fortran_int_t n, const float* x,
const fortran_int_t incx, const float* y, const fortran_int_t incy ) {
return BLAS_SDOT( &n, x, &incx, y, &incy );
}
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * double value-type.
//
inline double dot( const fortran_int_t n, const double* x,
const fortran_int_t incx, const double* y, const fortran_int_t incy ) {
return BLAS_DDOT( &n, x, &incx, y, &incy );
}
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * complex<float> value-type.
//
inline std::complex<float> dot( const fortran_int_t n,
const std::complex<float>* x, const fortran_int_t incx,
const std::complex<float>* y, const fortran_int_t incy ) {
return BLAS_CDOTU( &n, x, &incx, y, &incy );
}
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * complex<double> value-type.
//
inline std::complex<double> dot( const fortran_int_t n,
const std::complex<double>* x, const fortran_int_t incx,
const std::complex<double>* y, const fortran_int_t incy ) {
return BLAS_ZDOTU( &n, x, &incx, y, &incy );
}
#endif
} // namespace detail
//
// Value-type based template class. Use this class if you need a type
// for dispatching to dot.
//
template< typename Value >
struct dot_impl {
typedef Value value_type;
typedef typename remove_imaginary< Value >::type real_type;
typedef value_type result_type;
//
// Static member function that
// * Deduces the required arguments for dispatching to BLAS, and
// * Asserts that most arguments make sense.
//
template< typename VectorX, typename VectorY >
static result_type invoke( const VectorX& x, const VectorY& y ) {
namespace bindings = ::boost::numeric::bindings;
BOOST_STATIC_ASSERT( (is_same< typename remove_const<
typename bindings::value_type< VectorX >::type >::type,
typename remove_const< typename bindings::value_type<
VectorY >::type >::type >::value) );
BOOST_STATIC_ASSERT( (bindings::has_linear_array< VectorX >::value) );
BOOST_STATIC_ASSERT( (bindings::has_linear_array< VectorY >::value) );
return detail::dot( bindings::size(x),
bindings::begin_value(x), bindings::stride(x),
bindings::begin_value(y), bindings::stride(y) );
}
};
//
// Functions for direct use. These functions are overloaded for temporaries,
// so that wrapped types can still be passed and used for write-access. Calls
// to these functions are passed to the dot_impl classes. In the
// documentation, the const-overloads are collapsed to avoid a large number of
// prototypes which are very similar.
//
//
// Overloaded function for dot. Its overload differs for
//
template< typename VectorX, typename VectorY >
inline typename dot_impl< typename bindings::value_type<
VectorX >::type >::result_type
dot( const VectorX& x, const VectorY& y ) {
return dot_impl< typename bindings::value_type<
VectorX >::type >::invoke( x, y );
}
} // namespace blas
} // namespace bindings
} // namespace numeric
} // namespace boost
#endif

View File

@@ -0,0 +1,186 @@
//
// Copyright (c) 2002--2010
// Toon Knapen, Karl Meerbergen, Kresimir Fresl,
// Thomas Klimpel and Rutger ter Borg
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// THIS FILE IS AUTOMATICALLY GENERATED
// PLEASE DO NOT EDIT!
//
#ifndef BOOST_NUMERIC_BINDINGS_BLAS_LEVEL1_DOTC_HPP
#define BOOST_NUMERIC_BINDINGS_BLAS_LEVEL1_DOTC_HPP
#include <boost/assert.hpp>
#include <boost/numeric/bindings/begin.hpp>
#include <boost/numeric/bindings/has_linear_array.hpp>
#include <boost/numeric/bindings/is_mutable.hpp>
#include <boost/numeric/bindings/remove_imaginary.hpp>
#include <boost/numeric/bindings/size.hpp>
#include <boost/numeric/bindings/stride.hpp>
#include <boost/numeric/bindings/value_type.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/remove_const.hpp>
//
// The BLAS-backend is selected by defining a pre-processor variable,
// which can be one of
// * for CBLAS, define BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
// * for CUBLAS, define BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
// * netlib-compatible BLAS is the default
//
#if defined BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
#include <boost/numeric/bindings/blas/detail/cblas.h>
#include <boost/numeric/bindings/blas/detail/cblas_option.hpp>
#elif defined BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
#include <boost/numeric/bindings/blas/detail/cublas.h>
#include <boost/numeric/bindings/blas/detail/blas_option.hpp>
#else
#include <boost/numeric/bindings/blas/detail/blas.h>
#include <boost/numeric/bindings/blas/detail/blas_option.hpp>
#endif
namespace boost {
namespace numeric {
namespace bindings {
namespace blas {
//
// The detail namespace contains value-type-overloaded functions that
// dispatch to the appropriate back-end BLAS-routine.
//
namespace detail {
#if defined BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * complex<float> value-type.
//
inline std::complex<float> dotc( const int n, const std::complex<float>* x,
const int incx, const std::complex<float>* y, const int incy ) {
std::complex<float> result;
cblas_cdotc_sub( n, x, incx, y, incy, &result );
return result;
}
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * complex<double> value-type.
//
inline std::complex<double> dotc( const int n, const std::complex<double>* x,
const int incx, const std::complex<double>* y, const int incy ) {
std::complex<double> result;
cblas_zdotc_sub( n, x, incx, y, incy, &result );
return result;
}
#elif defined BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * complex<float> value-type.
//
inline std::complex<float> dotc( const int n, const std::complex<float>* x,
const int incx, const std::complex<float>* y, const int incy ) {
return cublasCdotc( n, x, incx, y, incy );
}
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * complex<double> value-type.
//
inline std::complex<double> dotc( const int n, const std::complex<double>* x,
const int incx, const std::complex<double>* y, const int incy ) {
return cublasZdotc( n, x, incx, y, incy );
}
#else
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * complex<float> value-type.
//
inline std::complex<float> dotc( const fortran_int_t n,
const std::complex<float>* x, const fortran_int_t incx,
const std::complex<float>* y, const fortran_int_t incy ) {
return BLAS_CDOTC( &n, x, &incx, y, &incy );
}
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * complex<double> value-type.
//
inline std::complex<double> dotc( const fortran_int_t n,
const std::complex<double>* x, const fortran_int_t incx,
const std::complex<double>* y, const fortran_int_t incy ) {
return BLAS_ZDOTC( &n, x, &incx, y, &incy );
}
#endif
} // namespace detail
//
// Value-type based template class. Use this class if you need a type
// for dispatching to dotc.
//
template< typename Value >
struct dotc_impl {
typedef Value value_type;
typedef typename remove_imaginary< Value >::type real_type;
typedef value_type result_type;
//
// Static member function that
// * Deduces the required arguments for dispatching to BLAS, and
// * Asserts that most arguments make sense.
//
template< typename VectorX, typename VectorY >
static result_type invoke( const VectorX& x, const VectorY& y ) {
namespace bindings = ::boost::numeric::bindings;
BOOST_STATIC_ASSERT( (is_same< typename remove_const<
typename bindings::value_type< VectorX >::type >::type,
typename remove_const< typename bindings::value_type<
VectorY >::type >::type >::value) );
BOOST_STATIC_ASSERT( (bindings::has_linear_array< VectorX >::value) );
BOOST_STATIC_ASSERT( (bindings::has_linear_array< VectorY >::value) );
return detail::dotc( bindings::size(x),
bindings::begin_value(x), bindings::stride(x),
bindings::begin_value(y), bindings::stride(y) );
}
};
//
// Functions for direct use. These functions are overloaded for temporaries,
// so that wrapped types can still be passed and used for write-access. Calls
// to these functions are passed to the dotc_impl classes. In the
// documentation, the const-overloads are collapsed to avoid a large number of
// prototypes which are very similar.
//
//
// Overloaded function for dotc. Its overload differs for
//
template< typename VectorX, typename VectorY >
inline typename dotc_impl< typename bindings::value_type<
VectorX >::type >::result_type
dotc( const VectorX& x, const VectorY& y ) {
return dotc_impl< typename bindings::value_type<
VectorX >::type >::invoke( x, y );
}
} // namespace blas
} // namespace bindings
} // namespace numeric
} // namespace boost
#endif

View File

@@ -0,0 +1,42 @@
//
// Copyright (c) 2002--2010
// Toon Knapen, Karl Meerbergen, Kresimir Fresl,
// Thomas Klimpel and Rutger ter Borg
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_NUMERIC_BINDINGS_BLAS_LEVEL1_DOTU_HPP
#define BOOST_NUMERIC_BINDINGS_BLAS_LEVEL1_DOTU_HPP
#include <boost/numeric/bindings/blas/level1/dot.hpp>
namespace boost {
namespace numeric {
namespace bindings {
namespace blas {
//
// dotu is a synonym for dot
//
// Functions for direct use. These functions are overloaded for temporaries,
// so that wrapped types can still be passed and used for write-access.
//
//
// Overloaded function for dotu.
//
template< typename VectorX, typename VectorY >
inline typename dot_impl< typename bindings::value_type< VectorX >::type >::result_type
dotu( const VectorX& x, const VectorY& y ) {
return dot_impl< typename bindings::value_type< VectorX >::type >::invoke( x, y );
}
} // namespace blas
} // namespace bindings
} // namespace numeric
} // namespace boost
#endif

View File

@@ -0,0 +1,232 @@
//
// Copyright (c) 2002--2010
// Toon Knapen, Karl Meerbergen, Kresimir Fresl,
// Thomas Klimpel and Rutger ter Borg
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// THIS FILE IS AUTOMATICALLY GENERATED
// PLEASE DO NOT EDIT!
//
#ifndef BOOST_NUMERIC_BINDINGS_BLAS_LEVEL1_IAMAX_HPP
#define BOOST_NUMERIC_BINDINGS_BLAS_LEVEL1_IAMAX_HPP
#include <boost/assert.hpp>
#include <boost/numeric/bindings/begin.hpp>
#include <boost/numeric/bindings/has_linear_array.hpp>
#include <boost/numeric/bindings/is_mutable.hpp>
#include <boost/numeric/bindings/remove_imaginary.hpp>
#include <boost/numeric/bindings/size.hpp>
#include <boost/numeric/bindings/stride.hpp>
#include <boost/numeric/bindings/value_type.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/remove_const.hpp>
//
// The BLAS-backend is selected by defining a pre-processor variable,
// which can be one of
// * for CBLAS, define BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
// * for CUBLAS, define BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
// * netlib-compatible BLAS is the default
//
#if defined BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
#include <boost/numeric/bindings/blas/detail/cblas.h>
#include <boost/numeric/bindings/blas/detail/cblas_option.hpp>
#elif defined BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
#include <boost/numeric/bindings/blas/detail/cublas.h>
#include <boost/numeric/bindings/blas/detail/blas_option.hpp>
#else
#include <boost/numeric/bindings/blas/detail/blas.h>
#include <boost/numeric/bindings/blas/detail/blas_option.hpp>
#endif
namespace boost {
namespace numeric {
namespace bindings {
namespace blas {
//
// The detail namespace contains value-type-overloaded functions that
// dispatch to the appropriate back-end BLAS-routine.
//
namespace detail {
#if defined BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * float value-type.
//
inline std::ptrdiff_t iamax( const int n, const float* x, const int incx ) {
return cblas_isamax( n, x, incx );
}
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * double value-type.
//
inline std::ptrdiff_t iamax( const int n, const double* x,
const int incx ) {
return cblas_idamax( n, x, incx );
}
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * complex<float> value-type.
//
inline std::ptrdiff_t iamax( const int n, const std::complex<float>* x,
const int incx ) {
return cblas_icamax( n, x, incx );
}
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * complex<double> value-type.
//
inline std::ptrdiff_t iamax( const int n, const std::complex<double>* x,
const int incx ) {
return cblas_izamax( n, x, incx );
}
#elif defined BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * float value-type.
//
inline std::ptrdiff_t iamax( const int n, const float* x, const int incx ) {
return cublasIsamax( n, x, incx );
}
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * double value-type.
//
inline std::ptrdiff_t iamax( const int n, const double* x,
const int incx ) {
return cublasIdamax( n, x, incx );
}
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * complex<float> value-type.
//
inline std::ptrdiff_t iamax( const int n, const std::complex<float>* x,
const int incx ) {
return cublasIcamax( n, x, incx );
}
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * complex<double> value-type.
//
inline std::ptrdiff_t iamax( const int n, const std::complex<double>* x,
const int incx ) {
return cublasIzamax( n, x, incx );
}
#else
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * float value-type.
//
inline std::ptrdiff_t iamax( const fortran_int_t n, const float* x,
const fortran_int_t incx ) {
return BLAS_ISAMAX( &n, x, &incx );
}
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * double value-type.
//
inline std::ptrdiff_t iamax( const fortran_int_t n, const double* x,
const fortran_int_t incx ) {
return BLAS_IDAMAX( &n, x, &incx );
}
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * complex<float> value-type.
//
inline std::ptrdiff_t iamax( const fortran_int_t n,
const std::complex<float>* x, const fortran_int_t incx ) {
return BLAS_ICAMAX( &n, x, &incx );
}
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * complex<double> value-type.
//
inline std::ptrdiff_t iamax( const fortran_int_t n,
const std::complex<double>* x, const fortran_int_t incx ) {
return BLAS_IZAMAX( &n, x, &incx );
}
#endif
} // namespace detail
//
// Value-type based template class. Use this class if you need a type
// for dispatching to iamax.
//
template< typename Value >
struct iamax_impl {
typedef Value value_type;
typedef typename remove_imaginary< Value >::type real_type;
typedef std::ptrdiff_t result_type;
//
// Static member function that
// * Deduces the required arguments for dispatching to BLAS, and
// * Asserts that most arguments make sense.
//
template< typename VectorX >
static result_type invoke( const VectorX& x ) {
namespace bindings = ::boost::numeric::bindings;
BOOST_STATIC_ASSERT( (bindings::has_linear_array< VectorX >::value) );
return detail::iamax( bindings::size(x),
bindings::begin_value(x), bindings::stride(x) );
}
};
//
// Functions for direct use. These functions are overloaded for temporaries,
// so that wrapped types can still be passed and used for write-access. Calls
// to these functions are passed to the iamax_impl classes. In the
// documentation, the const-overloads are collapsed to avoid a large number of
// prototypes which are very similar.
//
//
// Overloaded function for iamax. Its overload differs for
//
template< typename VectorX >
inline typename iamax_impl< typename bindings::value_type<
VectorX >::type >::result_type
iamax( const VectorX& x ) {
return iamax_impl< typename bindings::value_type<
VectorX >::type >::invoke( x );
}
} // namespace blas
} // namespace bindings
} // namespace numeric
} // namespace boost
#endif

View File

@@ -0,0 +1,230 @@
//
// Copyright (c) 2002--2010
// Toon Knapen, Karl Meerbergen, Kresimir Fresl,
// Thomas Klimpel and Rutger ter Borg
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// THIS FILE IS AUTOMATICALLY GENERATED
// PLEASE DO NOT EDIT!
//
#ifndef BOOST_NUMERIC_BINDINGS_BLAS_LEVEL1_NRM2_HPP
#define BOOST_NUMERIC_BINDINGS_BLAS_LEVEL1_NRM2_HPP
#include <boost/assert.hpp>
#include <boost/numeric/bindings/begin.hpp>
#include <boost/numeric/bindings/has_linear_array.hpp>
#include <boost/numeric/bindings/is_mutable.hpp>
#include <boost/numeric/bindings/remove_imaginary.hpp>
#include <boost/numeric/bindings/size.hpp>
#include <boost/numeric/bindings/stride.hpp>
#include <boost/numeric/bindings/value_type.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/remove_const.hpp>
//
// The BLAS-backend is selected by defining a pre-processor variable,
// which can be one of
// * for CBLAS, define BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
// * for CUBLAS, define BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
// * netlib-compatible BLAS is the default
//
#if defined BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
#include <boost/numeric/bindings/blas/detail/cblas.h>
#include <boost/numeric/bindings/blas/detail/cblas_option.hpp>
#elif defined BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
#include <boost/numeric/bindings/blas/detail/cublas.h>
#include <boost/numeric/bindings/blas/detail/blas_option.hpp>
#else
#include <boost/numeric/bindings/blas/detail/blas.h>
#include <boost/numeric/bindings/blas/detail/blas_option.hpp>
#endif
namespace boost {
namespace numeric {
namespace bindings {
namespace blas {
//
// The detail namespace contains value-type-overloaded functions that
// dispatch to the appropriate back-end BLAS-routine.
//
namespace detail {
#if defined BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * float value-type.
//
inline float nrm2( const int n, const float* x, const int incx ) {
return cblas_snrm2( n, x, incx );
}
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * double value-type.
//
inline double nrm2( const int n, const double* x, const int incx ) {
return cblas_dnrm2( n, x, incx );
}
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * complex<float> value-type.
//
inline float nrm2( const int n, const std::complex<float>* x,
const int incx ) {
return cblas_scnrm2( n, x, incx );
}
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * complex<double> value-type.
//
inline double nrm2( const int n, const std::complex<double>* x,
const int incx ) {
return cblas_dznrm2( n, x, incx );
}
#elif defined BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * float value-type.
//
inline float nrm2( const int n, const float* x, const int incx ) {
return cublasSnrm2( n, x, incx );
}
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * double value-type.
//
inline double nrm2( const int n, const double* x, const int incx ) {
return cublasDnrm2( n, x, incx );
}
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * complex<float> value-type.
//
inline float nrm2( const int n, const std::complex<float>* x,
const int incx ) {
return cublasScnrm2( n, x, incx );
}
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * complex<double> value-type.
//
inline double nrm2( const int n, const std::complex<double>* x,
const int incx ) {
return cublasDznrm2( n, x, incx );
}
#else
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * float value-type.
//
inline float nrm2( const fortran_int_t n, const float* x,
const fortran_int_t incx ) {
return BLAS_SNRM2( &n, x, &incx );
}
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * double value-type.
//
inline double nrm2( const fortran_int_t n, const double* x,
const fortran_int_t incx ) {
return BLAS_DNRM2( &n, x, &incx );
}
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * complex<float> value-type.
//
inline float nrm2( const fortran_int_t n, const std::complex<float>* x,
const fortran_int_t incx ) {
return BLAS_SCNRM2( &n, x, &incx );
}
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * complex<double> value-type.
//
inline double nrm2( const fortran_int_t n, const std::complex<double>* x,
const fortran_int_t incx ) {
return BLAS_DZNRM2( &n, x, &incx );
}
#endif
} // namespace detail
//
// Value-type based template class. Use this class if you need a type
// for dispatching to nrm2.
//
template< typename Value >
struct nrm2_impl {
typedef Value value_type;
typedef typename remove_imaginary< Value >::type real_type;
typedef real_type result_type;
//
// Static member function that
// * Deduces the required arguments for dispatching to BLAS, and
// * Asserts that most arguments make sense.
//
template< typename VectorX >
static result_type invoke( const VectorX& x ) {
namespace bindings = ::boost::numeric::bindings;
BOOST_STATIC_ASSERT( (bindings::has_linear_array< VectorX >::value) );
return detail::nrm2( bindings::size(x),
bindings::begin_value(x), bindings::stride(x) );
}
};
//
// Functions for direct use. These functions are overloaded for temporaries,
// so that wrapped types can still be passed and used for write-access. Calls
// to these functions are passed to the nrm2_impl classes. In the
// documentation, the const-overloads are collapsed to avoid a large number of
// prototypes which are very similar.
//
//
// Overloaded function for nrm2. Its overload differs for
//
template< typename VectorX >
inline typename nrm2_impl< typename bindings::value_type<
VectorX >::type >::result_type
nrm2( const VectorX& x ) {
return nrm2_impl< typename bindings::value_type<
VectorX >::type >::invoke( x );
}
} // namespace blas
} // namespace bindings
} // namespace numeric
} // namespace boost
#endif

View File

@@ -0,0 +1,150 @@
//
// Copyright (c) 2002--2010
// Toon Knapen, Karl Meerbergen, Kresimir Fresl,
// Thomas Klimpel and Rutger ter Borg
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// THIS FILE IS AUTOMATICALLY GENERATED
// PLEASE DO NOT EDIT!
//
#ifndef BOOST_NUMERIC_BINDINGS_BLAS_LEVEL1_PREC_DOT_HPP
#define BOOST_NUMERIC_BINDINGS_BLAS_LEVEL1_PREC_DOT_HPP
#include <boost/assert.hpp>
#include <boost/numeric/bindings/begin.hpp>
#include <boost/numeric/bindings/has_linear_array.hpp>
#include <boost/numeric/bindings/is_mutable.hpp>
#include <boost/numeric/bindings/remove_imaginary.hpp>
#include <boost/numeric/bindings/size.hpp>
#include <boost/numeric/bindings/stride.hpp>
#include <boost/numeric/bindings/value_type.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/remove_const.hpp>
//
// The BLAS-backend is selected by defining a pre-processor variable,
// which can be one of
// * for CBLAS, define BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
// * for CUBLAS, define BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
// * netlib-compatible BLAS is the default
//
#if defined BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
#include <boost/numeric/bindings/blas/detail/cblas.h>
#include <boost/numeric/bindings/blas/detail/cblas_option.hpp>
#elif defined BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
#include <boost/numeric/bindings/blas/detail/cublas.h>
#include <boost/numeric/bindings/blas/detail/blas_option.hpp>
#else
#include <boost/numeric/bindings/blas/detail/blas.h>
#include <boost/numeric/bindings/blas/detail/blas_option.hpp>
#endif
namespace boost {
namespace numeric {
namespace bindings {
namespace blas {
//
// The detail namespace contains value-type-overloaded functions that
// dispatch to the appropriate back-end BLAS-routine.
//
namespace detail {
#if defined BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * double value-type.
//
inline double prec_dot( const int n, const float* x, const int incx,
const float* y, const int incy ) {
return cblas_dsdot( n, x, incx, y, incy );
}
#elif defined BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * double value-type.
//
inline double prec_dot( const int n, const float* x, const int incx,
const float* y, const int incy ) {
return // NOT FOUND();
}
#else
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * double value-type.
//
inline double prec_dot( const fortran_int_t n, const float* x,
const fortran_int_t incx, const float* y, const fortran_int_t incy ) {
return BLAS_DSDOT( &n, x, &incx, y, &incy );
}
#endif
} // namespace detail
//
// Value-type based template class. Use this class if you need a type
// for dispatching to prec_dot.
//
template< typename Value >
struct prec_dot_impl {
typedef Value value_type;
typedef typename remove_imaginary< Value >::type real_type;
typedef double result_type;
//
// Static member function that
// * Deduces the required arguments for dispatching to BLAS, and
// * Asserts that most arguments make sense.
//
template< typename VectorX, typename VectorY >
static result_type invoke( const VectorX& x, const VectorY& y ) {
namespace bindings = ::boost::numeric::bindings;
BOOST_STATIC_ASSERT( (is_same< typename remove_const<
typename bindings::value_type< VectorX >::type >::type,
typename remove_const< typename bindings::value_type<
VectorY >::type >::type >::value) );
BOOST_STATIC_ASSERT( (bindings::has_linear_array< VectorX >::value) );
BOOST_STATIC_ASSERT( (bindings::has_linear_array< VectorY >::value) );
return detail::prec_dot( bindings::size(x),
bindings::begin_value(x), bindings::stride(x),
bindings::begin_value(y), bindings::stride(y) );
}
};
//
// Functions for direct use. These functions are overloaded for temporaries,
// so that wrapped types can still be passed and used for write-access. Calls
// to these functions are passed to the prec_dot_impl classes. In the
// documentation, the const-overloads are collapsed to avoid a large number of
// prototypes which are very similar.
//
//
// Overloaded function for prec_dot. Its overload differs for
//
template< typename VectorX, typename VectorY >
inline typename prec_dot_impl< typename bindings::value_type<
VectorX >::type >::result_type
prec_dot( const VectorX& x, const VectorY& y ) {
return prec_dot_impl< typename bindings::value_type<
VectorX >::type >::invoke( x, y );
}
} // namespace blas
} // namespace bindings
} // namespace numeric
} // namespace boost
#endif

View File

@@ -0,0 +1,250 @@
//
// Copyright (c) 2002--2010
// Toon Knapen, Karl Meerbergen, Kresimir Fresl,
// Thomas Klimpel and Rutger ter Borg
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// THIS FILE IS AUTOMATICALLY GENERATED
// PLEASE DO NOT EDIT!
//
#ifndef BOOST_NUMERIC_BINDINGS_BLAS_LEVEL1_ROT_HPP
#define BOOST_NUMERIC_BINDINGS_BLAS_LEVEL1_ROT_HPP
#include <boost/assert.hpp>
#include <boost/numeric/bindings/begin.hpp>
#include <boost/numeric/bindings/has_linear_array.hpp>
#include <boost/numeric/bindings/is_mutable.hpp>
#include <boost/numeric/bindings/remove_imaginary.hpp>
#include <boost/numeric/bindings/size.hpp>
#include <boost/numeric/bindings/stride.hpp>
#include <boost/numeric/bindings/value_type.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/remove_const.hpp>
//
// The BLAS-backend is selected by defining a pre-processor variable,
// which can be one of
// * for CBLAS, define BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
// * for CUBLAS, define BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
// * netlib-compatible BLAS is the default
//
#if defined BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
#include <boost/numeric/bindings/blas/detail/cblas.h>
#include <boost/numeric/bindings/blas/detail/cblas_option.hpp>
#elif defined BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
#include <boost/numeric/bindings/blas/detail/cublas.h>
#include <boost/numeric/bindings/blas/detail/blas_option.hpp>
#else
#include <boost/numeric/bindings/blas/detail/blas.h>
#include <boost/numeric/bindings/blas/detail/blas_option.hpp>
#endif
namespace boost {
namespace numeric {
namespace bindings {
namespace blas {
//
// The detail namespace contains value-type-overloaded functions that
// dispatch to the appropriate back-end BLAS-routine.
//
namespace detail {
#if defined BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * float value-type.
//
inline void rot( const int n, float* x, const int incx, float* y,
const int incy, const float c, const float s ) {
cblas_srot( n, x, incx, y, incy, c, s );
}
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * double value-type.
//
inline void rot( const int n, double* x, const int incx, double* y,
const int incy, const double c, const double s ) {
cblas_drot( n, x, incx, y, incy, c, s );
}
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * complex<float> value-type.
//
inline void rot( const int n, std::complex<float>* x, const int incx,
std::complex<float>* y, const int incy, const float c,
const float s ) {
// NOT FOUND();
}
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * complex<double> value-type.
//
inline void rot( const int n, std::complex<double>* x, const int incx,
std::complex<double>* y, const int incy, const double c,
const double s ) {
// NOT FOUND();
}
#elif defined BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * float value-type.
//
inline void rot( const int n, float* x, const int incx, float* y,
const int incy, const float c, const float s ) {
cublasSrot( n, x, incx, y, incy, c, s );
}
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * double value-type.
//
inline void rot( const int n, double* x, const int incx, double* y,
const int incy, const double c, const double s ) {
cublasDrot( n, x, incx, y, incy, c, s );
}
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * complex<float> value-type.
//
inline void rot( const int n, std::complex<float>* x, const int incx,
std::complex<float>* y, const int incy, const float c,
const float s ) {
cublasCsrot( n, x, incx, y, incy, c, s );
}
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * complex<double> value-type.
//
inline void rot( const int n, std::complex<double>* x, const int incx,
std::complex<double>* y, const int incy, const double c,
const double s ) {
cublasZdrot( n, x, incx, y, incy, c, s );
}
#else
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * float value-type.
//
inline void rot( const fortran_int_t n, float* x, const fortran_int_t incx,
float* y, const fortran_int_t incy, const float c, const float s ) {
BLAS_SROT( &n, x, &incx, y, &incy, &c, &s );
}
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * double value-type.
//
inline void rot( const fortran_int_t n, double* x, const fortran_int_t incx,
double* y, const fortran_int_t incy, const double c, const double s ) {
BLAS_DROT( &n, x, &incx, y, &incy, &c, &s );
}
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * complex<float> value-type.
//
inline void rot( const fortran_int_t n, std::complex<float>* x,
const fortran_int_t incx, std::complex<float>* y,
const fortran_int_t incy, const float c, const float s ) {
BLAS_CSROT( &n, x, &incx, y, &incy, &c, &s );
}
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * complex<double> value-type.
//
inline void rot( const fortran_int_t n, std::complex<double>* x,
const fortran_int_t incx, std::complex<double>* y,
const fortran_int_t incy, const double c, const double s ) {
BLAS_ZDROT( &n, x, &incx, y, &incy, &c, &s );
}
#endif
} // namespace detail
//
// Value-type based template class. Use this class if you need a type
// for dispatching to rot.
//
template< typename Value >
struct rot_impl {
typedef Value value_type;
typedef typename remove_imaginary< Value >::type real_type;
typedef void result_type;
//
// Static member function that
// * Deduces the required arguments for dispatching to BLAS, and
// * Asserts that most arguments make sense.
//
template< typename VectorX, typename VectorY >
static result_type invoke( VectorX& x, VectorY& y, const real_type c,
const real_type s ) {
namespace bindings = ::boost::numeric::bindings;
BOOST_STATIC_ASSERT( (is_same< typename remove_const<
typename bindings::value_type< VectorX >::type >::type,
typename remove_const< typename bindings::value_type<
VectorY >::type >::type >::value) );
BOOST_STATIC_ASSERT( (bindings::has_linear_array< VectorX >::value) );
BOOST_STATIC_ASSERT( (bindings::has_linear_array< VectorY >::value) );
detail::rot( bindings::size(x), bindings::begin_value(x),
bindings::stride(x), bindings::begin_value(y),
bindings::stride(y), c, s );
}
};
//
// Functions for direct use. These functions are overloaded for temporaries,
// so that wrapped types can still be passed and used for write-access. Calls
// to these functions are passed to the rot_impl classes. In the
// documentation, the const-overloads are collapsed to avoid a large number of
// prototypes which are very similar.
//
//
// Overloaded function for rot. Its overload differs for
//
template< typename VectorX, typename VectorY >
inline typename rot_impl< typename bindings::value_type<
VectorX >::type >::result_type
rot( VectorX& x, VectorY& y, const typename remove_imaginary<
typename bindings::value_type< VectorX >::type >::type c,
const typename remove_imaginary< typename bindings::value_type<
VectorX >::type >::type s ) {
rot_impl< typename bindings::value_type<
VectorX >::type >::invoke( x, y, c, s );
}
} // namespace blas
} // namespace bindings
} // namespace numeric
} // namespace boost
#endif

View File

@@ -0,0 +1,223 @@
//
// Copyright (c) 2002--2010
// Toon Knapen, Karl Meerbergen, Kresimir Fresl,
// Thomas Klimpel and Rutger ter Borg
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// THIS FILE IS AUTOMATICALLY GENERATED
// PLEASE DO NOT EDIT!
//
#ifndef BOOST_NUMERIC_BINDINGS_BLAS_LEVEL1_ROTG_HPP
#define BOOST_NUMERIC_BINDINGS_BLAS_LEVEL1_ROTG_HPP
#include <boost/assert.hpp>
#include <boost/numeric/bindings/begin.hpp>
#include <boost/numeric/bindings/is_mutable.hpp>
#include <boost/numeric/bindings/remove_imaginary.hpp>
#include <boost/numeric/bindings/size.hpp>
#include <boost/numeric/bindings/stride.hpp>
#include <boost/numeric/bindings/value_type.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/remove_const.hpp>
//
// The BLAS-backend is selected by defining a pre-processor variable,
// which can be one of
// * for CBLAS, define BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
// * for CUBLAS, define BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
// * netlib-compatible BLAS is the default
//
#if defined BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
#include <boost/numeric/bindings/blas/detail/cblas.h>
#include <boost/numeric/bindings/blas/detail/cblas_option.hpp>
#elif defined BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
#include <boost/numeric/bindings/blas/detail/cublas.h>
#include <boost/numeric/bindings/blas/detail/blas_option.hpp>
#else
#include <boost/numeric/bindings/blas/detail/blas.h>
#include <boost/numeric/bindings/blas/detail/blas_option.hpp>
#endif
namespace boost {
namespace numeric {
namespace bindings {
namespace blas {
//
// The detail namespace contains value-type-overloaded functions that
// dispatch to the appropriate back-end BLAS-routine.
//
namespace detail {
#if defined BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * float value-type.
//
inline void rotg( float& a, float& b, float& c, float& s ) {
cblas_srotg( &a, &b, &c, &s );
}
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * double value-type.
//
inline void rotg( double& a, double& b, double& c, double& s ) {
cblas_drotg( &a, &b, &c, &s );
}
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * complex<float> value-type.
//
inline void rotg( std::complex<float>& a, std::complex<float>& b, float& c,
std::complex<float>& s ) {
// NOT FOUND();
}
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * complex<double> value-type.
//
inline void rotg( std::complex<double>& a, std::complex<double>& b, double& c,
std::complex<double>& s ) {
// NOT FOUND();
}
#elif defined BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * float value-type.
//
inline void rotg( float& a, float& b, float& c, float& s ) {
cublasSrotg( &a, &b, &c, &s );
}
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * double value-type.
//
inline void rotg( double& a, double& b, double& c, double& s ) {
cublasDrotg( &a, &b, &c, &s );
}
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * complex<float> value-type.
//
inline void rotg( std::complex<float>& a, std::complex<float>& b, float& c,
std::complex<float>& s ) {
cublasCrotg( &a, b, &c, &s );
}
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * complex<double> value-type.
//
inline void rotg( std::complex<double>& a, std::complex<double>& b, double& c,
std::complex<double>& s ) {
cublasZrotg( &a, b, &c, &s );
}
#else
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * float value-type.
//
inline void rotg( float& a, float& b, float& c, float& s ) {
BLAS_SROTG( &a, &b, &c, &s );
}
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * double value-type.
//
inline void rotg( double& a, double& b, double& c, double& s ) {
BLAS_DROTG( &a, &b, &c, &s );
}
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * complex<float> value-type.
//
inline void rotg( std::complex<float>& a, std::complex<float>& b, float& c,
std::complex<float>& s ) {
BLAS_CROTG( &a, &b, &c, &s );
}
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * complex<double> value-type.
//
inline void rotg( std::complex<double>& a, std::complex<double>& b, double& c,
std::complex<double>& s ) {
BLAS_ZROTG( &a, &b, &c, &s );
}
#endif
} // namespace detail
//
// Value-type based template class. Use this class if you need a type
// for dispatching to rotg.
//
template< typename Value >
struct rotg_impl {
typedef Value value_type;
typedef typename remove_imaginary< Value >::type real_type;
typedef void result_type;
//
// Static member function that
// * Deduces the required arguments for dispatching to BLAS, and
// * Asserts that most arguments make sense.
//
static result_type invoke( value_type& a, value_type& b, real_type& c,
value_type& s ) {
namespace bindings = ::boost::numeric::bindings;
detail::rotg( a, b, c, s );
}
};
//
// Functions for direct use. These functions are overloaded for temporaries,
// so that wrapped types can still be passed and used for write-access. Calls
// to these functions are passed to the rotg_impl classes. In the
// documentation, the const-overloads are collapsed to avoid a large number of
// prototypes which are very similar.
//
//
// Overloaded function for rotg. Its overload differs for
//
template< typename Value >
inline typename rotg_impl< Value >::result_type
rotg( Value& a, Value& b, Value& c, Value& s ) {
rotg_impl< Value >::invoke( a, b, c, s );
}
} // namespace blas
} // namespace bindings
} // namespace numeric
} // namespace boost
#endif

View File

@@ -0,0 +1,187 @@
//
// Copyright (c) 2002--2010
// Toon Knapen, Karl Meerbergen, Kresimir Fresl,
// Thomas Klimpel and Rutger ter Borg
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// THIS FILE IS AUTOMATICALLY GENERATED
// PLEASE DO NOT EDIT!
//
#ifndef BOOST_NUMERIC_BINDINGS_BLAS_LEVEL1_ROTM_HPP
#define BOOST_NUMERIC_BINDINGS_BLAS_LEVEL1_ROTM_HPP
#include <boost/assert.hpp>
#include <boost/numeric/bindings/begin.hpp>
#include <boost/numeric/bindings/has_linear_array.hpp>
#include <boost/numeric/bindings/is_mutable.hpp>
#include <boost/numeric/bindings/remove_imaginary.hpp>
#include <boost/numeric/bindings/size.hpp>
#include <boost/numeric/bindings/stride.hpp>
#include <boost/numeric/bindings/value_type.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/remove_const.hpp>
//
// The BLAS-backend is selected by defining a pre-processor variable,
// which can be one of
// * for CBLAS, define BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
// * for CUBLAS, define BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
// * netlib-compatible BLAS is the default
//
#if defined BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
#include <boost/numeric/bindings/blas/detail/cblas.h>
#include <boost/numeric/bindings/blas/detail/cblas_option.hpp>
#elif defined BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
#include <boost/numeric/bindings/blas/detail/cublas.h>
#include <boost/numeric/bindings/blas/detail/blas_option.hpp>
#else
#include <boost/numeric/bindings/blas/detail/blas.h>
#include <boost/numeric/bindings/blas/detail/blas_option.hpp>
#endif
namespace boost {
namespace numeric {
namespace bindings {
namespace blas {
//
// The detail namespace contains value-type-overloaded functions that
// dispatch to the appropriate back-end BLAS-routine.
//
namespace detail {
#if defined BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * float value-type.
//
inline void rotm( const int n, float* x, const int incx, float* y,
const int incy, float* param ) {
cblas_srotm( n, x, incx, y, incy, param );
}
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * double value-type.
//
inline void rotm( const int n, double* x, const int incx, double* y,
const int incy, double* param ) {
cblas_drotm( n, x, incx, y, incy, param );
}
#elif defined BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * float value-type.
//
inline void rotm( const int n, float* x, const int incx, float* y,
const int incy, float* param ) {
cublasSrotm( n, x, incx, y, incy, param );
}
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * double value-type.
//
inline void rotm( const int n, double* x, const int incx, double* y,
const int incy, double* param ) {
cublasDrotm( n, x, incx, y, incy, param );
}
#else
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * float value-type.
//
inline void rotm( const fortran_int_t n, float* x, const fortran_int_t incx,
float* y, const fortran_int_t incy, float* param ) {
BLAS_SROTM( &n, x, &incx, y, &incy, param );
}
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * double value-type.
//
inline void rotm( const fortran_int_t n, double* x, const fortran_int_t incx,
double* y, const fortran_int_t incy, double* param ) {
BLAS_DROTM( &n, x, &incx, y, &incy, param );
}
#endif
} // namespace detail
//
// Value-type based template class. Use this class if you need a type
// for dispatching to rotm.
//
template< typename Value >
struct rotm_impl {
typedef Value value_type;
typedef typename remove_imaginary< Value >::type real_type;
typedef void result_type;
//
// Static member function that
// * Deduces the required arguments for dispatching to BLAS, and
// * Asserts that most arguments make sense.
//
template< typename VectorX, typename VectorY, typename VectorPARAM >
static result_type invoke( VectorX& x, VectorY& y, VectorPARAM& param ) {
namespace bindings = ::boost::numeric::bindings;
BOOST_STATIC_ASSERT( (is_same< typename remove_const<
typename bindings::value_type< VectorX >::type >::type,
typename remove_const< typename bindings::value_type<
VectorY >::type >::type >::value) );
BOOST_STATIC_ASSERT( (is_same< typename remove_const<
typename bindings::value_type< VectorX >::type >::type,
typename remove_const< typename bindings::value_type<
VectorPARAM >::type >::type >::value) );
BOOST_STATIC_ASSERT( (bindings::has_linear_array< VectorX >::value) );
BOOST_STATIC_ASSERT( (bindings::has_linear_array< VectorY >::value) );
BOOST_STATIC_ASSERT( (bindings::is_mutable< VectorX >::value) );
BOOST_STATIC_ASSERT( (bindings::is_mutable< VectorY >::value) );
BOOST_STATIC_ASSERT( (bindings::is_mutable< VectorPARAM >::value) );
detail::rotm( bindings::size(x), bindings::begin_value(x),
bindings::stride(x), bindings::begin_value(y),
bindings::stride(y), bindings::begin_value(param) );
}
};
//
// Functions for direct use. These functions are overloaded for temporaries,
// so that wrapped types can still be passed and used for write-access. Calls
// to these functions are passed to the rotm_impl classes. In the
// documentation, the const-overloads are collapsed to avoid a large number of
// prototypes which are very similar.
//
//
// Overloaded function for rotm. Its overload differs for
//
template< typename VectorX, typename VectorY, typename VectorPARAM >
inline typename rotm_impl< typename bindings::value_type<
VectorX >::type >::result_type
rotm( VectorX& x, VectorY& y, VectorPARAM& param ) {
rotm_impl< typename bindings::value_type<
VectorX >::type >::invoke( x, y, param );
}
} // namespace blas
} // namespace bindings
} // namespace numeric
} // namespace boost
#endif

View File

@@ -0,0 +1,179 @@
//
// Copyright (c) 2002--2010
// Toon Knapen, Karl Meerbergen, Kresimir Fresl,
// Thomas Klimpel and Rutger ter Borg
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// THIS FILE IS AUTOMATICALLY GENERATED
// PLEASE DO NOT EDIT!
//
#ifndef BOOST_NUMERIC_BINDINGS_BLAS_LEVEL1_ROTMG_HPP
#define BOOST_NUMERIC_BINDINGS_BLAS_LEVEL1_ROTMG_HPP
#include <boost/assert.hpp>
#include <boost/numeric/bindings/begin.hpp>
#include <boost/numeric/bindings/is_mutable.hpp>
#include <boost/numeric/bindings/remove_imaginary.hpp>
#include <boost/numeric/bindings/size.hpp>
#include <boost/numeric/bindings/stride.hpp>
#include <boost/numeric/bindings/value_type.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/remove_const.hpp>
//
// The BLAS-backend is selected by defining a pre-processor variable,
// which can be one of
// * for CBLAS, define BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
// * for CUBLAS, define BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
// * netlib-compatible BLAS is the default
//
#if defined BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
#include <boost/numeric/bindings/blas/detail/cblas.h>
#include <boost/numeric/bindings/blas/detail/cblas_option.hpp>
#elif defined BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
#include <boost/numeric/bindings/blas/detail/cublas.h>
#include <boost/numeric/bindings/blas/detail/blas_option.hpp>
#else
#include <boost/numeric/bindings/blas/detail/blas.h>
#include <boost/numeric/bindings/blas/detail/blas_option.hpp>
#endif
namespace boost {
namespace numeric {
namespace bindings {
namespace blas {
//
// The detail namespace contains value-type-overloaded functions that
// dispatch to the appropriate back-end BLAS-routine.
//
namespace detail {
#if defined BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * float value-type.
//
inline void rotmg( float& d1, float& d2, float& x1, const float y1,
float* sparam ) {
cblas_srotmg( &d1, &d2, &x1, y1, sparam );
}
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * double value-type.
//
inline void rotmg( double& d1, double& d2, double& x1, const double y1,
double* dparam ) {
cblas_drotmg( &d1, &d2, &x1, y1, dparam );
}
#elif defined BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * float value-type.
//
inline void rotmg( float& d1, float& d2, float& x1, const float y1,
float* sparam ) {
cublasSrotmg( &d1, &d2, &x1, &y1, sparam );
}
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * double value-type.
//
inline void rotmg( double& d1, double& d2, double& x1, const double y1,
double* dparam ) {
cublasDrotmg( &d1, &d2, &x1, &y1, dparam );
}
#else
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * float value-type.
//
inline void rotmg( float& d1, float& d2, float& x1, const float y1,
float* sparam ) {
BLAS_SROTMG( &d1, &d2, &x1, &y1, sparam );
}
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * double value-type.
//
inline void rotmg( double& d1, double& d2, double& x1, const double y1,
double* dparam ) {
BLAS_DROTMG( &d1, &d2, &x1, &y1, dparam );
}
#endif
} // namespace detail
//
// Value-type based template class. Use this class if you need a type
// for dispatching to rotmg.
//
template< typename Value >
struct rotmg_impl {
typedef Value value_type;
typedef typename remove_imaginary< Value >::type real_type;
typedef void result_type;
//
// Static member function that
// * Deduces the required arguments for dispatching to BLAS, and
// * Asserts that most arguments make sense.
//
template< typename VectorDPARAM >
static result_type invoke( real_type& d1, real_type& d2, real_type& x1,
const real_type y1, VectorDPARAM& dparam ) {
namespace bindings = ::boost::numeric::bindings;
BOOST_STATIC_ASSERT( (bindings::is_mutable< VectorDPARAM >::value) );
detail::rotmg( d1, d2, x1, y1, bindings::begin_value(dparam) );
}
};
//
// Functions for direct use. These functions are overloaded for temporaries,
// so that wrapped types can still be passed and used for write-access. Calls
// to these functions are passed to the rotmg_impl classes. In the
// documentation, the const-overloads are collapsed to avoid a large number of
// prototypes which are very similar.
//
//
// Overloaded function for rotmg. Its overload differs for
//
template< typename VectorDPARAM >
inline typename rotmg_impl< typename bindings::value_type<
VectorDPARAM >::type >::result_type
rotmg( typename remove_imaginary< typename bindings::value_type<
VectorDPARAM >::type >::type& d1, typename remove_imaginary<
typename bindings::value_type< VectorDPARAM >::type >::type& d2,
typename remove_imaginary< typename bindings::value_type<
VectorDPARAM >::type >::type& x1, const typename remove_imaginary<
typename bindings::value_type< VectorDPARAM >::type >::type y1,
VectorDPARAM& dparam ) {
rotmg_impl< typename bindings::value_type<
VectorDPARAM >::type >::invoke( d1, d2, x1, y1, dparam );
}
} // namespace blas
} // namespace bindings
} // namespace numeric
} // namespace boost
#endif

View File

@@ -0,0 +1,291 @@
//
// Copyright (c) 2002--2010
// Toon Knapen, Karl Meerbergen, Kresimir Fresl,
// Thomas Klimpel and Rutger ter Borg
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// THIS FILE IS AUTOMATICALLY GENERATED
// PLEASE DO NOT EDIT!
//
#ifndef BOOST_NUMERIC_BINDINGS_BLAS_LEVEL1_SCAL_HPP
#define BOOST_NUMERIC_BINDINGS_BLAS_LEVEL1_SCAL_HPP
#include <boost/assert.hpp>
#include <boost/numeric/bindings/begin.hpp>
#include <boost/numeric/bindings/has_linear_array.hpp>
#include <boost/numeric/bindings/is_mutable.hpp>
#include <boost/numeric/bindings/remove_imaginary.hpp>
#include <boost/numeric/bindings/size.hpp>
#include <boost/numeric/bindings/stride.hpp>
#include <boost/numeric/bindings/value_type.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/remove_const.hpp>
//
// The BLAS-backend is selected by defining a pre-processor variable,
// which can be one of
// * for CBLAS, define BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
// * for CUBLAS, define BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
// * netlib-compatible BLAS is the default
//
#if defined BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
#include <boost/numeric/bindings/blas/detail/cblas.h>
#include <boost/numeric/bindings/blas/detail/cblas_option.hpp>
#elif defined BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
#include <boost/numeric/bindings/blas/detail/cublas.h>
#include <boost/numeric/bindings/blas/detail/blas_option.hpp>
#else
#include <boost/numeric/bindings/blas/detail/blas.h>
#include <boost/numeric/bindings/blas/detail/blas_option.hpp>
#endif
namespace boost {
namespace numeric {
namespace bindings {
namespace blas {
//
// The detail namespace contains value-type-overloaded functions that
// dispatch to the appropriate back-end BLAS-routine.
//
namespace detail {
#if defined BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * float value-type.
//
inline void scal( const int n, const float a, float* x, const int incx ) {
cblas_sscal( n, a, x, incx );
}
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * double value-type.
//
inline void scal( const int n, const double a, double* x, const int incx ) {
cblas_dscal( n, a, x, incx );
}
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * combined float and complex<float> value-type.
//
inline void scal( const int n, const float a, std::complex<float>* x,
const int incx ) {
cblas_csscal( n, a, x, incx );
}
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * combined double and complex<double> value-type.
//
inline void scal( const int n, const double a, std::complex<double>* x,
const int incx ) {
cblas_zdscal( n, a, x, incx );
}
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * complex<float> value-type.
//
inline void scal( const int n, const std::complex<float> a,
std::complex<float>* x, const int incx ) {
cblas_cscal( n, &a, x, incx );
}
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * complex<double> value-type.
//
inline void scal( const int n, const std::complex<double> a,
std::complex<double>* x, const int incx ) {
cblas_zscal( n, &a, x, incx );
}
#elif defined BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * float value-type.
//
inline void scal( const int n, const float a, float* x, const int incx ) {
cublasSscal( n, a, x, incx );
}
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * double value-type.
//
inline void scal( const int n, const double a, double* x, const int incx ) {
cublasDscal( n, a, x, incx );
}
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * combined float and complex<float> value-type.
//
inline void scal( const int n, const float a, std::complex<float>* x,
const int incx ) {
cublasCsscal( n, a, x, incx );
}
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * combined double and complex<double> value-type.
//
inline void scal( const int n, const double a, std::complex<double>* x,
const int incx ) {
cublasZdscal( n, a, x, incx );
}
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * complex<float> value-type.
//
inline void scal( const int n, const std::complex<float> a,
std::complex<float>* x, const int incx ) {
cublasCscal( n, a, x, incx );
}
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * complex<double> value-type.
//
inline void scal( const int n, const std::complex<double> a,
std::complex<double>* x, const int incx ) {
cublasZscal( n, a, x, incx );
}
#else
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * float value-type.
//
inline void scal( const fortran_int_t n, const float a, float* x,
const fortran_int_t incx ) {
BLAS_SSCAL( &n, &a, x, &incx );
}
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * double value-type.
//
inline void scal( const fortran_int_t n, const double a, double* x,
const fortran_int_t incx ) {
BLAS_DSCAL( &n, &a, x, &incx );
}
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * combined float and complex<float> value-type.
//
inline void scal( const fortran_int_t n, const float a,
std::complex<float>* x, const fortran_int_t incx ) {
BLAS_CSSCAL( &n, &a, x, &incx );
}
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * combined double and complex<double> value-type.
//
inline void scal( const fortran_int_t n, const double a,
std::complex<double>* x, const fortran_int_t incx ) {
BLAS_ZDSCAL( &n, &a, x, &incx );
}
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * complex<float> value-type.
//
inline void scal( const fortran_int_t n, const std::complex<float> a,
std::complex<float>* x, const fortran_int_t incx ) {
BLAS_CSCAL( &n, &a, x, &incx );
}
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * complex<double> value-type.
//
inline void scal( const fortran_int_t n, const std::complex<double> a,
std::complex<double>* x, const fortran_int_t incx ) {
BLAS_ZSCAL( &n, &a, x, &incx );
}
#endif
} // namespace detail
//
// Value-type based template class. Use this class if you need a type
// for dispatching to scal.
//
template< typename Value >
struct scal_impl {
typedef Value value_type;
typedef typename remove_imaginary< Value >::type real_type;
typedef void result_type;
//
// Static member function that
// * Deduces the required arguments for dispatching to BLAS, and
// * Asserts that most arguments make sense.
//
template< typename ScalarA, typename VectorX >
static result_type invoke( const ScalarA a, VectorX& x ) {
namespace bindings = ::boost::numeric::bindings;
BOOST_STATIC_ASSERT( (bindings::has_linear_array< VectorX >::value) );
BOOST_STATIC_ASSERT( (bindings::is_mutable< VectorX >::value) );
detail::scal( bindings::size(x), a, bindings::begin_value(x),
bindings::stride(x) );
}
};
//
// Functions for direct use. These functions are overloaded for temporaries,
// so that wrapped types can still be passed and used for write-access. Calls
// to these functions are passed to the scal_impl classes. In the
// documentation, the const-overloads are collapsed to avoid a large number of
// prototypes which are very similar.
//
//
// Overloaded function for scal. Its overload differs for
//
template< typename ScalarA, typename VectorX >
inline typename scal_impl< typename bindings::value_type<
VectorX >::type >::result_type
scal( const ScalarA a, VectorX& x ) {
scal_impl< typename bindings::value_type<
VectorX >::type >::invoke( a, x );
}
} // namespace blas
} // namespace bindings
} // namespace numeric
} // namespace boost
#endif

View File

@@ -0,0 +1,62 @@
//
// Copyright (c) 2002--2010
// Toon Knapen, Karl Meerbergen, Kresimir Fresl,
// Thomas Klimpel and Rutger ter Borg
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_NUMERIC_BINDINGS_BLAS_LEVEL1_SET_HPP
#define BOOST_NUMERIC_BINDINGS_BLAS_LEVEL1_SET_HPP
#include <boost/assert.hpp>
#include <boost/numeric/bindings/begin.hpp>
#include <boost/numeric/bindings/end.hpp>
#include <boost/numeric/bindings/is_mutable.hpp>
#include <boost/numeric/bindings/value_type.hpp>
#include <boost/static_assert.hpp>
namespace boost {
namespace numeric {
namespace bindings {
namespace blas {
//
// set is an extension, not part of the BLAS API.
//
// TODO implement ATLAS backend call(s)
//
// Functions for direct use. These functions are overloaded for temporaries,
// so that wrapped types can still be passed and used for write-access.
//
//
// Overloaded function for set. Its overload differs for
// * VectorX&
//
template< typename VectorX >
inline void
set( const typename bindings::value_type< VectorX >::type a, VectorX& x ) {
BOOST_STATIC_ASSERT( (bindings::is_mutable< VectorX >::value) );
std::fill( bindings::begin(x), bindings::end(x), a );
}
//
// Overloaded function for set. Its overload differs for
// * const VectorX&
//
template< typename VectorX >
inline void
set( const typename bindings::value_type< const VectorX >::type a, const VectorX& x ) {
BOOST_STATIC_ASSERT( (bindings::is_mutable< const VectorX >::value) );
std::fill( bindings::begin(x), bindings::end(x), a );
}
} // namespace blas
} // namespace bindings
} // namespace numeric
} // namespace boost
#endif

View File

@@ -0,0 +1,244 @@
//
// Copyright (c) 2002--2010
// Toon Knapen, Karl Meerbergen, Kresimir Fresl,
// Thomas Klimpel and Rutger ter Borg
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// THIS FILE IS AUTOMATICALLY GENERATED
// PLEASE DO NOT EDIT!
//
#ifndef BOOST_NUMERIC_BINDINGS_BLAS_LEVEL1_SWAP_HPP
#define BOOST_NUMERIC_BINDINGS_BLAS_LEVEL1_SWAP_HPP
#include <boost/assert.hpp>
#include <boost/numeric/bindings/begin.hpp>
#include <boost/numeric/bindings/has_linear_array.hpp>
#include <boost/numeric/bindings/is_mutable.hpp>
#include <boost/numeric/bindings/remove_imaginary.hpp>
#include <boost/numeric/bindings/size.hpp>
#include <boost/numeric/bindings/stride.hpp>
#include <boost/numeric/bindings/value_type.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/remove_const.hpp>
//
// The BLAS-backend is selected by defining a pre-processor variable,
// which can be one of
// * for CBLAS, define BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
// * for CUBLAS, define BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
// * netlib-compatible BLAS is the default
//
#if defined BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
#include <boost/numeric/bindings/blas/detail/cblas.h>
#include <boost/numeric/bindings/blas/detail/cblas_option.hpp>
#elif defined BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
#include <boost/numeric/bindings/blas/detail/cublas.h>
#include <boost/numeric/bindings/blas/detail/blas_option.hpp>
#else
#include <boost/numeric/bindings/blas/detail/blas.h>
#include <boost/numeric/bindings/blas/detail/blas_option.hpp>
#endif
namespace boost {
namespace numeric {
namespace bindings {
namespace blas {
//
// The detail namespace contains value-type-overloaded functions that
// dispatch to the appropriate back-end BLAS-routine.
//
namespace detail {
#if defined BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * float value-type.
//
inline void swap( const int n, float* x, const int incx, float* y,
const int incy ) {
cblas_sswap( n, x, incx, y, incy );
}
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * double value-type.
//
inline void swap( const int n, double* x, const int incx, double* y,
const int incy ) {
cblas_dswap( n, x, incx, y, incy );
}
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * complex<float> value-type.
//
inline void swap( const int n, std::complex<float>* x, const int incx,
std::complex<float>* y, const int incy ) {
cblas_cswap( n, x, incx, y, incy );
}
//
// Overloaded function for dispatching to
// * CBLAS backend, and
// * complex<double> value-type.
//
inline void swap( const int n, std::complex<double>* x, const int incx,
std::complex<double>* y, const int incy ) {
cblas_zswap( n, x, incx, y, incy );
}
#elif defined BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * float value-type.
//
inline void swap( const int n, float* x, const int incx, float* y,
const int incy ) {
cublasSswap( n, x, incx, y, incy );
}
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * double value-type.
//
inline void swap( const int n, double* x, const int incx, double* y,
const int incy ) {
cublasDswap( n, x, incx, y, incy );
}
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * complex<float> value-type.
//
inline void swap( const int n, std::complex<float>* x, const int incx,
std::complex<float>* y, const int incy ) {
cublasCswap( n, x, incx, y, incy );
}
//
// Overloaded function for dispatching to
// * CUBLAS backend, and
// * complex<double> value-type.
//
inline void swap( const int n, std::complex<double>* x, const int incx,
std::complex<double>* y, const int incy ) {
cublasZswap( n, x, incx, y, incy );
}
#else
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * float value-type.
//
inline void swap( const fortran_int_t n, float* x, const fortran_int_t incx,
float* y, const fortran_int_t incy ) {
BLAS_SSWAP( &n, x, &incx, y, &incy );
}
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * double value-type.
//
inline void swap( const fortran_int_t n, double* x, const fortran_int_t incx,
double* y, const fortran_int_t incy ) {
BLAS_DSWAP( &n, x, &incx, y, &incy );
}
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * complex<float> value-type.
//
inline void swap( const fortran_int_t n, std::complex<float>* x,
const fortran_int_t incx, std::complex<float>* y,
const fortran_int_t incy ) {
BLAS_CSWAP( &n, x, &incx, y, &incy );
}
//
// Overloaded function for dispatching to
// * netlib-compatible BLAS backend (the default), and
// * complex<double> value-type.
//
inline void swap( const fortran_int_t n, std::complex<double>* x,
const fortran_int_t incx, std::complex<double>* y,
const fortran_int_t incy ) {
BLAS_ZSWAP( &n, x, &incx, y, &incy );
}
#endif
} // namespace detail
//
// Value-type based template class. Use this class if you need a type
// for dispatching to swap.
//
template< typename Value >
struct swap_impl {
typedef Value value_type;
typedef typename remove_imaginary< Value >::type real_type;
typedef void result_type;
//
// Static member function that
// * Deduces the required arguments for dispatching to BLAS, and
// * Asserts that most arguments make sense.
//
template< typename VectorX, typename VectorY >
static result_type invoke( VectorX& x, VectorY& y ) {
namespace bindings = ::boost::numeric::bindings;
BOOST_STATIC_ASSERT( (is_same< typename remove_const<
typename bindings::value_type< VectorX >::type >::type,
typename remove_const< typename bindings::value_type<
VectorY >::type >::type >::value) );
BOOST_STATIC_ASSERT( (bindings::has_linear_array< VectorX >::value) );
BOOST_STATIC_ASSERT( (bindings::has_linear_array< VectorY >::value) );
BOOST_STATIC_ASSERT( (bindings::is_mutable< VectorX >::value) );
BOOST_STATIC_ASSERT( (bindings::is_mutable< VectorY >::value) );
detail::swap( bindings::size(x), bindings::begin_value(x),
bindings::stride(x), bindings::begin_value(y),
bindings::stride(y) );
}
};
//
// Functions for direct use. These functions are overloaded for temporaries,
// so that wrapped types can still be passed and used for write-access. Calls
// to these functions are passed to the swap_impl classes. In the
// documentation, the const-overloads are collapsed to avoid a large number of
// prototypes which are very similar.
//
//
// Overloaded function for swap. Its overload differs for
//
template< typename VectorX, typename VectorY >
inline typename swap_impl< typename bindings::value_type<
VectorX >::type >::result_type
swap( VectorX& x, VectorY& y ) {
swap_impl< typename bindings::value_type<
VectorX >::type >::invoke( x, y );
}
} // namespace blas
} // namespace bindings
} // namespace numeric
} // namespace boost
#endif