Matrix has got the ArrayMap method, but vector does not.
/// <summary>
/// In place element-by-element mapping of an arbitrary function, <c>A[i] = mapping(A[i])</c>.
/// </summary>
/// <seealso cref="ArrayMap(IVector, Converter<double, double>)"/>
public
void
ArrayMap(
Converter<double, double> mapping
)
{
for(int i = 0; i < _data.Length; i++)
{
_data[i] = mapping(_data[i]);
}
}
/// <summary>
/// Element-by-element mapping of an arbitrary function, <c>result[i] = mapping(M[i])</c>.
/// </summary>
/// <seealso cref="ArrayMap(Converter<double, double>)"/>
public static
Vector
ArrayMap(
IVector v,
Converter<double, double> mapping
)
{
double[ newData = new double[v.Length];
for(int i = 0; i < v.Length; i++)
{
newData[i] = mapping(v[i]);
}
return new Vector(newData);
}