Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r59004 - sandbox/numeric_bindings/libs/numeric/bindings/atlas
From: rutger_at_[hidden]
Date: 2010-01-14 10:59:40


Author: rutger
Date: 2010-01-14 10:59:39 EST (Thu, 14 Jan 2010)
New Revision: 59004
URL: http://svn.boost.org/trac/boost/changeset/59004

Log:
ported the first atlas regression to blas

Text files modified:
   sandbox/numeric_bindings/libs/numeric/bindings/atlas/ublas_symm2.cc | 50 ++++++++++++++++++++--------------------
   sandbox/numeric_bindings/libs/numeric/bindings/atlas/utils.h | 44 ++++++++++++++++-------------------
   2 files changed, 45 insertions(+), 49 deletions(-)

Modified: sandbox/numeric_bindings/libs/numeric/bindings/atlas/ublas_symm2.cc
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/atlas/ublas_symm2.cc (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/atlas/ublas_symm2.cc 2010-01-14 10:59:39 EST (Thu, 14 Jan 2010)
@@ -8,16 +8,16 @@
 #include <stddef.h>
 #include <iostream>
 #include <complex>
-#include <boost/numeric/bindings/atlas/cblas1.hpp>
-#include <boost/numeric/bindings/atlas/cblas2.hpp>
-#include <boost/numeric/bindings/traits/ublas_vector.hpp>
-#include <boost/numeric/bindings/traits/ublas_symmetric.hpp>
-#include <boost/numeric/bindings/traits/ublas_hermitian.hpp>
+#include <boost/numeric/bindings/blas/level2.hpp>
+#include <boost/numeric/bindings/ublas/vector.hpp>
+#include <boost/numeric/bindings/ublas/matrix.hpp>
+#include <boost/numeric/bindings/ublas/symmetric.hpp>
+#include <boost/numeric/bindings/ublas/hermitian.hpp>
 #include "utils.h"
 
 namespace ublas = boost::numeric::ublas;
-namespace atlas = boost::numeric::bindings::atlas;
-namespace traits = boost::numeric::bindings::traits;
+namespace blas = boost::numeric::bindings::blas;
+namespace bindings = boost::numeric::bindings;
 
 using std::cout;
 using std::cin;
@@ -75,7 +75,7 @@
   cout << endl;
 
   vct_t vx (n), vy (n);
- atlas::set (1., vx);
+ std::fill( bindings::begin(vx), bindings::end(vx), 1. );
   print_v (vx, "vx");
 
   ucsymm_t ucs (n, n);
@@ -109,34 +109,34 @@
   cout << endl;
 
   // vy = symm vx
- atlas::spmv (ucs, vx, vy);
+ blas::spmv( 1, ucs, vx, 0, vy );
   print_v (vy, "vy = ucs vx");
   cout << endl;
- atlas::spmv (1, lcs, vx, 0, vy);
+ blas::spmv (1, lcs, vx, 0, vy);
   print_v (vy, "vy = lcs vx");
   cout << endl;
- atlas::spmv (1., urs, vx, 0., vy);
+ blas::spmv (1., urs, vx, 0., vy);
   print_v (vy, "vy = urs vx");
   cout << endl;
- atlas::spmv (1.0f, lrs, vx, 0.0f, vy);
+ blas::spmv (1.0f, lrs, vx, 0.0f, vy);
   print_v (vy, "vy = lrs vx");
   cout << endl;
 
 #ifdef F_COMPILATION_FAILURE
 
- atlas::symv (ucs, vx, vy);
+ blas::symv (ucs, vx, vy);
   print_v (vy, "vy = ucs vx");
   cout << endl;
 
- atlas::hpmv (lcs, vx, vy);
+ blas::hpmv (lcs, vx, vy);
   print_v (vy, "vy = lcs vx");
   cout << endl;
 
- atlas::gemv (urs, vx, vy);
+ blas::gemv (urs, vx, vy);
   print_v (vy, "vy = urs vx");
   cout << endl;
 
- atlas::spmv (cmplx_t (1., 0.), lrs, vx, cmplx_t (0., 0.), vy);
+ blas::spmv (cmplx_t (1., 0.), lrs, vx, cmplx_t (0., 0.), vy);
   print_v (vy, "vy = lrs vx");
   cout << endl;
 
@@ -149,7 +149,7 @@
   size_t n2 = 3;
 
   cvct_t cvx (n2), cvy (n2);
- atlas::set (1., cvx);
+ std::fill( bindings::begin(cvx), bindings::end(cvx), 1. );
   print_v (cvx, "cvx");
   cout << endl;
 
@@ -185,16 +185,16 @@
   cout << endl;
 
   // cvy = herm cvx
- atlas::hpmv (uch, cvx, cvy);
+ blas::hpmv (1, uch, cvx, 0, cvy);
   print_v (cvy, "cvy = uch cvx");
   cout << endl;
- atlas::hpmv (1, lch, cvx, 0, cvy);
+ blas::hpmv (1, lch, cvx, 0, cvy);
   print_v (cvy, "cvy = lch cvx");
   cout << endl;
- atlas::hpmv (1., urh, cvx, 0., cvy);
+ blas::hpmv (1., urh, cvx, 0., cvy);
   print_v (cvy, "cvy = urh cvx");
   cout << endl;
- atlas::hpmv (cmplx_t (1., 0.), lrh, cvx, cmplx_t (0., 0.), cvy);
+ blas::hpmv (cmplx_t (1., 0.), lrh, cvx, cmplx_t (0., 0.), cvy);
   print_v (cvy, "cvy = lrh cvx");
   cout << endl;
 
@@ -235,16 +235,16 @@
   cout << endl;
 
   // cvy = herma cvx
- atlas::hemv (ucha, cvx, cvy);
+ blas::hemv (1, ucha, cvx, 0, cvy);
   print_v (cvy, "cvy = uch cvx");
   cout << endl;
- atlas::hemv (1, lcha, cvx, 0, cvy);
+ blas::hemv (1, lcha, cvx, 0, cvy);
   print_v (cvy, "cvy = lch cvx");
   cout << endl;
- atlas::hemv (1., urha, cvx, 0., cvy);
+ blas::hemv (1., urha, cvx, 0., cvy);
   print_v (cvy, "cvy = urh cvx");
   cout << endl;
- atlas::hemv (cmplx_t (1., 0.), lrha, cvx, cmplx_t (0., 0.), cvy);
+ blas::hemv (cmplx_t (1., 0.), lrha, cvx, cmplx_t (0., 0.), cvy);
   print_v (cvy, "cvy = lrh cvx");
   cout << endl;
 

Modified: sandbox/numeric_bindings/libs/numeric/bindings/atlas/utils.h
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/atlas/utils.h (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/atlas/utils.h 2010-01-14 10:59:39 EST (Thu, 14 Jan 2010)
@@ -4,8 +4,12 @@
 
 #include <stddef.h>
 #include <iostream>
-#include <boost/numeric/bindings/traits/traits.hpp>
+#include <boost/numeric/bindings/value.hpp>
+#include <boost/numeric/bindings/begin.hpp>
+#include <boost/numeric/bindings/end.hpp>
+#include <boost/numeric/bindings/size.hpp>
 
+namespace bindings = ::boost::numeric::bindings;
 
 ///////////////////////////////
 // vectors
@@ -15,7 +19,7 @@
 template <typename V>
 struct vct_access_traits {
   typedef typename
- boost::numeric::bindings::traits::vector_traits<V>::value_type val_t;
+ bindings::value<V>::type val_t;
   typedef val_t& ref_t;
   static ref_t elem (V& v, size_t i) { return v[i]; }
 };
@@ -23,7 +27,7 @@
 template <typename V>
 struct vct_access_traits<V const> {
   typedef typename
- boost::numeric::bindings::traits::vector_traits<V>::value_type val_t;
+ bindings::value<V>::type val_t;
   typedef val_t ref_t;
   static ref_t elem (V const& v, size_t i) { return v[i]; }
 };
@@ -84,7 +88,7 @@
 
 template <typename F, typename V>
 void init_v (V& v, F f = F()) {
- size_t sz = boost::numeric::bindings::traits::vector_size (v);
+ size_t sz = bindings::size (v);
   for (std::size_t i = 0; i < sz; ++i) {
 #ifndef BOOST_NUMERIC_BINDINGS_POOR_MANS_TRAITS
     elem_v (v, i) = f (i);
@@ -99,7 +103,7 @@
 void print_v (V const& v, char const* ch = 0) {
   if (ch)
     std::cout << ch << ": ";
- size_t sz = boost::numeric::bindings::traits::vector_size (v);
+ size_t sz = bindings::size (v);
   for (std::size_t i = 0; i < sz; ++i) {
 #ifndef BOOST_NUMERIC_BINDINGS_POOR_MANS_TRAITS
     std::cout << elem_v (v, i) << " ";
@@ -120,7 +124,7 @@
 struct matr_access_traits {
   typedef typename
   M::reference ref_t;
- //boost::numeric::bindings::traits::matrix_traits<M>::value_type val_t;
+ //bindings::value<M>::type val_t;
   //typedef val_t& ref_t;
   static ref_t elem (M& m, size_t i, size_t j) { return m (i, j); }
 };
@@ -128,7 +132,7 @@
 template <typename M>
 struct matr_access_traits<M const> {
   typedef typename
- boost::numeric::bindings::traits::matrix_traits<M>::value_type val_t;
+ bindings::value<M>::type val_t;
   typedef val_t ref_t;
   static ref_t elem (M const& m, size_t i, size_t j) { return m (i, j); }
 };
@@ -156,8 +160,8 @@
 
 template <typename F, typename M>
 void init_m (M& m, F f = F()) {
- size_t sz1 = boost::numeric::bindings::traits::matrix_size1 (m);
- size_t sz2 = boost::numeric::bindings::traits::matrix_size2 (m);
+ size_t sz1 = bindings::size1 (m);
+ size_t sz2 = bindings::size2 (m);
   for (std::size_t i = 0; i < sz1; ++i)
     for (std::size_t j = 0; j < sz2; ++j) {
 #ifndef BOOST_NUMERIC_BINDINGS_POOR_MANS_TRAITS
@@ -170,7 +174,7 @@
 
 template <typename M>
 void init_symm (M& m, char uplo = 'f') {
- size_t n = boost::numeric::bindings::traits::matrix_size1 (m);
+ size_t n = bindings::size1 (m);
   for (size_t i = 0; i < n; ++i) {
 #ifndef BOOST_NUMERIC_BINDINGS_POOR_MANS_TRAITS
     elem_m (m, i, i) = n;
@@ -206,8 +210,8 @@
 void print_m (M const& m, char const* ch = 0) {
   if (ch)
     std::cout << ch << ":\n";
- size_t sz1 = boost::numeric::bindings::traits::matrix_size1 (m);
- size_t sz2 = boost::numeric::bindings::traits::matrix_size2 (m);
+ size_t sz1 = bindings::size1 (m);
+ size_t sz2 = bindings::size2 (m);
   for (std::size_t i = 0 ; i < sz1 ; ++i) {
     for (std::size_t j = 0 ; j < sz2 ; ++j) {
 #ifndef BOOST_NUMERIC_BINDINGS_POOR_MANS_TRAITS
@@ -225,19 +229,11 @@
 void print_m_data (M const& m, char const* ch = 0) {
   if (ch)
     std::cout << ch << " data:\n";
-//#ifndef BOOST_NUMERIC_BINDINGS_POOR_MANS_TRAITS
- size_t sz =
- boost::numeric::bindings::traits::matrix_traits<M const>::num_rows(m)*
- boost::numeric::bindings::traits::matrix_traits<M const>::num_columns(m);
- typename
- boost::numeric::bindings::traits::matrix_traits<M const>::pointer st =
- boost::numeric::bindings::traits::matrix_traits<M const>::storage (m);
- for (std::size_t i = 0 ; i < sz ; ++i, ++st)
- std::cout << *st << " ";
+ using namespace boost::numeric::bindings;
+ std::copy( begin_value( m ), end_value( m ), std::ostream_iterator
+ < typename value< const M >::type >( std::cout, " " ) );
   std::cout << std::endl;
-//#else
-// std::cout << ".. poor man\'s traits :o(" << std::endl;
-//#endif
+
 }
 
 #endif


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