|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r50057 - in sandbox/boost/numeric/bindings: lapack traits
From: thomas.klimpel_at_[hidden]
Date: 2008-12-01 16:44:23
Author: klimpel
Date: 2008-12-01 16:44:22 EST (Mon, 01 Dec 2008)
New Revision: 50057
URL: http://svn.boost.org/trac/boost/changeset/50057
Log:
added Vardan Akopian's bindings for gbtrf / gbtrs
Added:
sandbox/boost/numeric/bindings/lapack/gbsv.hpp (contents, props changed)
Text files modified:
sandbox/boost/numeric/bindings/lapack/hbev.hpp | 1 -
sandbox/boost/numeric/bindings/lapack/hbevx.hpp | 1 -
sandbox/boost/numeric/bindings/lapack/lapack.h | 17 ++++++++++++++++-
sandbox/boost/numeric/bindings/lapack/lapack_names.h | 6 ++++++
sandbox/boost/numeric/bindings/traits/ublas_banded.hpp | 4 ++--
5 files changed, 24 insertions(+), 5 deletions(-)
Added: sandbox/boost/numeric/bindings/lapack/gbsv.hpp
==============================================================================
--- (empty file)
+++ sandbox/boost/numeric/bindings/lapack/gbsv.hpp 2008-12-01 16:44:22 EST (Mon, 01 Dec 2008)
@@ -0,0 +1,174 @@
+//
+// Copyright Vardan Akopian 2007
+//
+// 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_LAPACK_GBSV_HPP
+#define BOOST_NUMERIC_BINDINGS_LAPACK_GBSV_HPP
+
+#include <boost/numeric/bindings/traits/traits.hpp>
+#include <boost/numeric/bindings/traits/type_traits.hpp>
+#include <boost/numeric/bindings/lapack/lapack.h>
+
+
+#ifndef BOOST_NUMERIC_BINDINGS_NO_STRUCTURE_CHECK
+# include <boost/static_assert.hpp>
+# include <boost/type_traits/is_same.hpp>
+#endif
+
+
+namespace boost { namespace numeric { namespace bindings {
+
+ namespace lapack {
+
+
+ namespace detail {
+ inline
+ void gbtrf (int const n, int const m, int const kl, int const ku,
+ float* ab, int const ldab, int* ipiv, int* info)
+ {
+ LAPACK_SGBTRF (&n, &m, &kl, &ku, ab, &ldab, ipiv, info);
+ }
+ inline
+ void gbtrf (int const n, int const m, int const kl, int const ku,
+ double* ab, int const ldab, int* ipiv, int* info)
+ {
+ LAPACK_DGBTRF (&n, &m, &kl, &ku, ab, &ldab, ipiv, info);
+ }
+ inline
+ void gbtrf (int const n, int const m, int const kl, int const ku,
+ traits::complex_f* ab, int const ldab, int* ipiv, int* info)
+ {
+ LAPACK_CGBTRF (&n, &m, &kl, &ku, traits::complex_ptr(ab), &ldab, ipiv, info);
+ }
+ inline
+ void gbtrf (int const n, int const m, int const kl, int const ku,
+ traits::complex_d* ab, int const ldab, int* ipiv, int* info)
+ {
+ LAPACK_ZGBTRF (&n, &m, &kl, &ku, traits::complex_ptr(ab), &ldab, ipiv, info);
+ }
+ }
+
+ template <typename MatrA, typename IVec>
+ inline
+ int gbtrf (MatrA& a, IVec& ipiv) {
+
+#ifndef BOOST_NUMERIC_BINDINGS_NO_STRUCTURE_CHECK
+ BOOST_STATIC_ASSERT((boost::is_same<
+ typename traits::matrix_traits<MatrA>::matrix_structure,
+ traits::banded_t
+ >::value));
+ BOOST_STATIC_ASSERT((boost::is_same<
+ typename traits::matrix_traits<MatrA>::ordering_type,
+ traits::row_major_t
+ >::value));
+#endif
+
+ int const n = traits::matrix_size1 (a);
+ int const m = traits::matrix_size2 (a);
+ assert (traits::vector_size (ipiv) == (m < n ? m : n));
+
+ // if the matrix has kl lower and ku upper diagonals, then we should have
+ // allocated kl lower and kl+ku upper diagonals
+ int const kl = traits::matrix_lower_bandwidth (a);
+ int const ku = traits::matrix_upper_bandwidth (a) - kl;
+ int const ld = traits::leading_dimension (a);
+
+ assert(ku >= 0);
+
+ int info;
+ detail::gbtrf (n, m, kl, ku,
+ traits::matrix_storage (a),
+ ld,
+ traits::vector_storage (ipiv),
+ &info);
+ return info;
+ }
+
+
+ namespace detail {
+ inline
+ void gbtrs (char const trans, int const n, int const kl, int const ku, int const m,
+ float const* ab, int const ldab, int const* ipiv,
+ float* b, int const ldb, int* info)
+ {
+ LAPACK_SGBTRS (&trans, &n, &kl, &ku, &m, ab, &ldab, ipiv, b, &ldb, info);
+ }
+ inline
+ void gbtrs (char const trans, int const n, int const kl, int const ku, int const m,
+ double const* ab, int const ldab, int const* ipiv,
+ double* b, int const ldb, int* info)
+ {
+ LAPACK_DGBTRS (&trans, &n, &kl, &ku, &m, ab, &ldab, ipiv, b, &ldb, info);
+ }
+ inline
+ void gbtrs (char const trans, int const n, int const kl, int const ku, int const m,
+ traits::complex_f const* ab, int const ldab, int const* ipiv,
+ traits::complex_f* b, int const ldb, int* info)
+ {
+ LAPACK_CGBTRS (&trans, &n, &kl, &ku, &m, traits::complex_ptr(ab), &ldab, ipiv, traits::complex_ptr(b), &ldb, info);
+ }
+ inline
+ void gbtrs (char const trans, int const n, int const kl, int const ku, int const m,
+ traits::complex_d const* ab, int const ldab, int const* ipiv,
+ traits::complex_d* b, int const ldb, int* info)
+ {
+ LAPACK_ZGBTRS (&trans, &n, &kl, &ku, &m, traits::complex_ptr(ab), &ldab, ipiv, traits::complex_ptr(b), &ldb, info);
+ }
+ }
+
+
+ template <typename MatrA, typename MatrB, typename IVec>
+ inline
+ int gbtrs (char const trans, MatrA const& a, IVec const& ipiv, MatrB& b)
+ {
+ assert (trans == 'N' || trans == 'T' || trans == 'C');
+
+#ifndef BOOST_NUMERIC_BINDINGS_NO_STRUCTURE_CHECK
+ BOOST_STATIC_ASSERT((boost::is_same<
+ typename traits::matrix_traits<MatrA>::matrix_structure,
+ traits::banded_t
+ >::value));
+#endif
+
+ int const n = traits::matrix_size1 (a);
+ assert (n == traits::matrix_size2 (a));
+ assert (n == traits::matrix_size1 (b));
+ assert (n == traits::vector_size (ipiv));
+
+ // if the matrix has kl lower and ku upper diagonals, then we should have
+ // allocated kl lower and kl+ku upper diagonals
+ int const kl = traits::matrix_lower_bandwidth (a);
+ int const ku = traits::matrix_upper_bandwidth (a) - kl;
+ int const ld = traits::leading_dimension (a);
+
+ assert(ku >= 0);
+
+ int info;
+ detail::gbtrs (trans, n, kl, ku, traits::matrix_size2 (b),
+#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
+ traits::matrix_storage (a),
+#else
+ traits::matrix_storage_const (a),
+#endif
+ ld,
+#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
+ traits::vector_storage (ipiv),
+#else
+ traits::vector_storage_const (ipiv),
+#endif
+ traits::matrix_storage (b),
+ traits::leading_dimension (b),
+ &info);
+ return info;
+ }
+
+
+ }
+
+}}}
+
+#endif
Modified: sandbox/boost/numeric/bindings/lapack/hbev.hpp
==============================================================================
--- sandbox/boost/numeric/bindings/lapack/hbev.hpp (original)
+++ sandbox/boost/numeric/bindings/lapack/hbev.hpp 2008-12-01 16:44:22 EST (Mon, 01 Dec 2008)
@@ -14,7 +14,6 @@
#ifndef BOOST_NUMERIC_BINDINGS_LAPACK_HBEV_HPP
#define BOOST_NUMERIC_BINDINGS_LAPACK_HBEV_HPP
-#include <boost/numeric/bindings/traits/type.hpp>
#include <boost/numeric/bindings/traits/traits.hpp>
#include <boost/numeric/bindings/traits/type_traits.hpp>
#include <boost/numeric/bindings/lapack/lapack.h>
Modified: sandbox/boost/numeric/bindings/lapack/hbevx.hpp
==============================================================================
--- sandbox/boost/numeric/bindings/lapack/hbevx.hpp (original)
+++ sandbox/boost/numeric/bindings/lapack/hbevx.hpp 2008-12-01 16:44:22 EST (Mon, 01 Dec 2008)
@@ -15,7 +15,6 @@
#ifndef BOOST_NUMERIC_BINDINGS_LAPACK_HBEVX_HPP
#define BOOST_NUMERIC_BINDINGS_LAPACK_HBEVX_HPP
-#include <boost/numeric/bindings/traits/type.hpp>
#include <boost/numeric/bindings/traits/traits.hpp>
#include <boost/numeric/bindings/traits/type_traits.hpp>
#include <boost/numeric/bindings/lapack/lapack.h>
Modified: sandbox/boost/numeric/bindings/lapack/lapack.h
==============================================================================
--- sandbox/boost/numeric/bindings/lapack/lapack.h (original)
+++ sandbox/boost/numeric/bindings/lapack/lapack.h 2008-12-01 16:44:22 EST (Mon, 01 Dec 2008)
@@ -333,12 +333,27 @@
/* banded */
+ void LAPACK_SGBTRF (int const* n, int const* m, int const* kl, int const* ku,
+ float* ab, int const* ldab, int* ipiv, int* info);
void LAPACK_DGBTRF (int const* n, int const* m, int const* kl, int const* ku,
double* ab, int const* ldab, int* ipiv, int* info);
-
+ void LAPACK_CGBTRF (int const* n, int const* m, int const* kl, int const* ku,
+ fcomplex_t* ab, int const* ldab, int* ipiv, int* info);
+ void LAPACK_ZGBTRF (int const* n, int const* m, int const* kl, int const* ku,
+ dcomplex_t* ab, int const* ldab, int* ipiv, int* info);
+
+ void LAPACK_SGBTRS (char const* trans, int const* n, int const* kl, int const* ku, int const* nrhs,
+ float const* ab, int const* ldab, int const* ipiv,
+ float* b, int const* ldb, int* info);
void LAPACK_DGBTRS (char const* trans, int const* n, int const* kl, int const* ku, int const* nrhs,
double const* ab, int const* ldab, int const* ipiv,
double* b, int const* ldb, int* info);
+ void LAPACK_CGBTRS (char const* trans, int const* n, int const* kl, int const* ku, int const* nrhs,
+ fcomplex_t const* ab, int const* ldab, int const* ipiv,
+ fcomplex_t* b, int const* ldb, int* info);
+ void LAPACK_ZGBTRS (char const* trans, int const* n, int const* kl, int const* ku, int const* nrhs,
+ dcomplex_t const* ab, int const* ldab, int const* ipiv,
+ dcomplex_t* b, int const* ldb, int* info);
/**********************************************************************/
Modified: sandbox/boost/numeric/bindings/lapack/lapack_names.h
==============================================================================
--- sandbox/boost/numeric/bindings/lapack/lapack_names.h (original)
+++ sandbox/boost/numeric/bindings/lapack/lapack_names.h 2008-12-01 16:44:22 EST (Mon, 01 Dec 2008)
@@ -169,8 +169,14 @@
/* banded solve */
+#define LAPACK_SGBTRF FORTRAN_ID( sgbtrf )
#define LAPACK_DGBTRF FORTRAN_ID( dgbtrf )
+#define LAPACK_CGBTRF FORTRAN_ID( cgbtrf )
+#define LAPACK_ZGBTRF FORTRAN_ID( zgbtrf )
+#define LAPACK_SGBTRS FORTRAN_ID( sgbtrs )
#define LAPACK_DGBTRS FORTRAN_ID( dgbtrs )
+#define LAPACK_CGBTRS FORTRAN_ID( cgbtrs )
+#define LAPACK_ZGBTRS FORTRAN_ID( zgbtrs )
/********************************************/
Modified: sandbox/boost/numeric/bindings/traits/ublas_banded.hpp
==============================================================================
--- sandbox/boost/numeric/bindings/traits/ublas_banded.hpp (original)
+++ sandbox/boost/numeric/bindings/traits/ublas_banded.hpp 2008-12-01 16:44:22 EST (Mon, 01 Dec 2008)
@@ -65,8 +65,8 @@
typedef typename detail::generate_const<M,ArrT>::type array_type ;
return vector_traits<array_type>::storage (m.data());
}
- static std::ptrdiff_t size1 (matrix_type& m) { return m.size1(); }
- static std::ptrdiff_t size2 (matrix_type& m) { return m.size2(); }
+ static std::ptrdiff_t num_rows (matrix_type& m) { return m.size1(); }
+ static std::ptrdiff_t num_columns (matrix_type& m) { return m.size2(); }
static std::ptrdiff_t lower_bandwidth (matrix_type& m) { return m.lower() ; }
static std::ptrdiff_t upper_bandwidth (matrix_type& m) { return m.upper() ; }
static std::ptrdiff_t storage_size (matrix_type& m) { return size1 (m) * size2 (m); }
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk