Boost logo

Ublas :

From: Manoj Rajagopalan (rmanoj_at_[hidden])
Date: 2006-11-14 11:52:20


Hi

   I am interested in creating an absolute value unary functor that
accepts a vector or matrix as its input. When used in an expression, it
must return, element-wise, the absolute value of the elements of the
original vector.

// ------ Example:

vector<int> a(5), b(5), c(5);
// assume a = { -1, 2, -3, 4, -5}
// b = { 5, 5, 5, 5, 5 }

c = a + b;
d = abs(a) + b;

// Now, c = { 4, 7, 2, 9, 0}
// d = { 6, 7, 8, 9, 10}

// ----- End of example

1. Is there already a function in ublas that does something like this? I
looked up the documentation and some of the ublas code but I couldn't
locate anything but I feel such a requirement should be fairly common so
I may have missed something.

2. Are there similar unary functors for sin, cos etc that operate
element-wise on vectors?

3. If not, would there be any interest in including these in ublas?
Blitz++ offers all such unary functors.

Thanks
Manoj