I think i achieved this behavior by using the size1 or size2 member functions depending on row or column iteration and used ublas::row or ublas::column to get a matrix_row or matrix_column

so pseudo code would look something like this

// loop over columns getting each row
for (i = 0; i  < m.size1(); ++i)
{
    matrix_row row = ublas::row(m, i);
    std::accumlate(row.begin(), row.end(), 0.0);
}

probably not the best way, but it worked

On Wed, Jul 8, 2009 at 6:50 PM, Jesse Perla <jesseperla@gmail.com> wrote:
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());

_______________________________________________
ublas mailing list
ublas@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/ublas
Sent to: manning.jesse@gmail.com