Boost logo

Ublas :

From: Jesse Manning (manning.jesse_at_[hidden])
Date: 2007-09-10 09:51:01

This might not be quite what you are asking since this pertains to uBLAS
vectors, but you might be able to do the same type of thing with matrices.
For vectors I usually do this for sqrt:

namespace ublas = boost::numeric::ublas;

template <typename T, typename A>
ublas::vector<T, A> Sqrt(const ublas::vector<T, A>& origVector)
   // create return vector with same size as input vector
   ublas::vector<T, A> sqrtVector(origVector.size());

   // take the sqrt of each element
   ublas::vector<T, A>::iterator sqrtIter;
   sqrtIter = std::transform(origVector.begin(),

   return sqrtVector;

Also I think I had a compile problem with the above code using the
1.34.1release of boost because the sqrt function call is now
"type_sqrt" instead
of just "sqrt".

On 9/10/07, Mei, Longyu <LMei_at_[hidden]> wrote:
> Hi there,
> I want to do sqrt on matrix. For example if I have a matrix A [4, 9,
> 16], after the sqrt(A), the expected result should be a matrix B [2, 3,
> 4]. Can ublas does this on one function call? Thanks
> James
> ****************************************************************
> The information transmitted in this message is confidential and may be
> privileged. Any review, retransmission, dissemination, or other use of this
> information by persons or entities other than the intended recipient is
> prohibited. If you are not the intended recipient, please notify Analogic
> Corporation immediately - by replying to this message or by sending an email
> to DeliveryErrors_at_[hidden] - and destroy all copies of this
> information, including any attachments, without reading or disclosing them.
> Thank you.
> _______________________________________________
> ublas mailing list
> ublas_at_[hidden]