|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r71112 - in sandbox/numeric_bindings: boost/numeric/bindings/lapack/driver libs/numeric/bindings/tools/templates/driver
From: rutger_at_[hidden]
Date: 2011-04-08 03:06:02
Author: rutger
Date: 2011-04-08 03:06:01 EDT (Fri, 08 Apr 2011)
New Revision: 71112
URL: http://svn.boost.org/trac/boost/changeset/71112
Log:
Updated minimum workspace computation for gesvd
Text files modified:
sandbox/numeric_bindings/boost/numeric/bindings/lapack/driver/gesvd.hpp | 30 +++++++++++++++++++++---------
sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/gesvd.hpp | 20 +++++++++++++++++---
2 files changed, 38 insertions(+), 12 deletions(-)
Modified: sandbox/numeric_bindings/boost/numeric/bindings/lapack/driver/gesvd.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/lapack/driver/gesvd.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/lapack/driver/gesvd.hpp 2011-04-08 03:06:01 EDT (Fri, 08 Apr 2011)
@@ -167,7 +167,7 @@
std::ptrdiff_t >(bindings::size_row(a),
bindings::size_column(a)) );
BOOST_ASSERT( bindings::size(work.select(real_type())) >=
- min_size_work( bindings::size_row(a),
+ min_size_work( jobu, jobvt, bindings::size_row(a),
bindings::size_column(a) ));
BOOST_ASSERT( bindings::size_column(a) >= 0 );
BOOST_ASSERT( bindings::size_minor(a) == 1 ||
@@ -205,8 +205,8 @@
MatrixA& a, VectorS& s, MatrixU& u, MatrixVT& vt,
minimal_workspace ) {
namespace bindings = ::boost::numeric::bindings;
- bindings::detail::array< real_type > tmp_work( min_size_work(
- bindings::size_row(a), bindings::size_column(a) ) );
+ bindings::detail::array< real_type > tmp_work( min_size_work( jobu,
+ jobvt, bindings::size_row(a), bindings::size_column(a) ) );
return invoke( jobu, jobvt, a, s, u, vt, workspace( tmp_work ) );
}
@@ -239,12 +239,24 @@
// Static member function that returns the minimum size of
// workspace-array work.
//
- static std::ptrdiff_t min_size_work( const std::ptrdiff_t m,
- const std::ptrdiff_t n ) {
- std::ptrdiff_t minmn = std::min< std::ptrdiff_t >( m, n );
- return std::max< std::ptrdiff_t >( 1, std::max<
- std::ptrdiff_t >( 3*minmn+std::max< std::ptrdiff_t >(m,n),
- 5*minmn ) );
+ static std::ptrdiff_t min_size_work( const char jobu, const char jobvt,
+ const std::ptrdiff_t m, const std::ptrdiff_t n ) {
+ //
+ // Contributed by Marco Guazzone
+ //
+ if ( m >= n ) {
+ if ( jobu == 'N' ) {
+ return 5*n;
+ } else {
+ return std::max< std::ptrdiff_t >(3*n+m,5*n);
+ }
+ } else {
+ if (jobvt == 'N') {
+ return 5*m;
+ } else {
+ return std::max< std::ptrdiff_t >(3*m+n,5*m);
+ }
+ }
}
};
Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/gesvd.hpp
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/gesvd.hpp (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/gesvd.hpp 2011-04-08 03:06:01 EDT (Fri, 08 Apr 2011)
@@ -1,8 +1,22 @@
$TEMPLATE[gesvd.real.min_size_work.args]
-M,N
+JOBU,JOBVT,M,N
$TEMPLATE[gesvd.real.min_size_work]
-$INTEGER_TYPE minmn = std::min< $INTEGER_TYPE >( m, n );
-return std::max< $INTEGER_TYPE >( 1, std::max< $INTEGER_TYPE >( 3*minmn+std::max< $INTEGER_TYPE >(m,n), 5*minmn ) );
+//
+// Contributed by Marco Guazzone
+//
+if ( m >= n ) {
+ if ( jobu == 'N' ) {
+ return 5*n;
+ } else {
+ return std::max< $INTEGER_TYPE >(3*n+m,5*n);
+ }
+} else {
+ if (jobvt == 'N') {
+ return 5*m;
+ } else {
+ return std::max< $INTEGER_TYPE >(3*m+n,5*m);
+ }
+}
$TEMPLATE[gesvd.complex.extra_variables]
MINMN
$TEMPLATE[gesvd.complex.extra_opt_variables]
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