Boost logo

Boost Users :

Subject: [Boost-users] vector iterator element-wise operation
From: Max S. Kaznady (max.kaznady_at_[hidden])
Date: 2010-07-04 18:16:38


I'm using this example:
http://stackoverflow.com/questions/773667/element-wise-operations-with-boost-c-ublas-matrix-and-vector-types

and for some reason the function std::fill compiles and works just
fine, but functions std::for_each and std::transform do no compile -
saying that there is no compatible function found for the iterator
type.

using namespace boost::numeric::ublas;
// Create a 30 element vector of doubles
vector<double> vec(30);
// Assign 8.0 to each element.
std::fill(vec.begin(), vec.end(), 8.0);
// Perform the "Gamma" function on each element and assign the result back
// to the original element in the vector.
// The next line does not compile, but the fill function compiles and
executes just fine:
std::transform(vec.begin(), vec.end(), vec.begin(), boost::math::tgamma);

What's wrong?

Cheers,
Max


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net