DavRay DavRay - 26 days ago 9
C++ Question

What way is efficient to apply a function over each element of a vector<vector<float>>?

Suppose i have a

vector<vector<float>>
called
a
. I wanna apply a function over each element of this array. What way is efficient and optimized to do this? I tried with this:
sqrt(a,a)
, (Suppose i want to apply
sqrt
over each element of
a
)but i got this Exception error:
An unhandled exception of type 'System.Runtime.InteropServices.SEHException' occurred
.

Answer Source

Use std::transform() or std::for_each() — both will give you optimal results. (Precluding any unstated odd environmental factors.)