$include_dir="/home/hyper-archives/ublas/include"; include("$include_dir/msg-header.inc") ?>
Subject: [ublas] Row iterators and std
From: Jesse Perla (jesseperla_at_[hidden])
Date: 2009-07-08 18:50:13
Sorry, forgot to post my intended usage.  I wanted to use std::transform
over the rows.  Consider something like this and couldn't do to the
dereference of the row_iterator gives a double type.  Are there any other
ways to do this pattern in ublas?
struct vector_sum
{
  template<class VectorType>
  double operator()(const VectorType& vec)
  {
     return std::accumulate(vec.begin(), vec.end(), 0.0);
  }
};
ublas::matrix<double> A(2.2);
ublas::vector<double> sums(2);
//Sum over rows.
std::transform(A.begin1(), A.end1(), sums.begin(), vector_sum());