diff --git a/src/Numerics/LinearAlgebra/Vector.cs b/src/Numerics/LinearAlgebra/Vector.cs index 641cfe9f..04b168fd 100644 --- a/src/Numerics/LinearAlgebra/Vector.cs +++ b/src/Numerics/LinearAlgebra/Vector.cs @@ -391,6 +391,7 @@ namespace MathNet.Numerics.LinearAlgebra public void Map(Func f, Vector result, Zeros zeros = Zeros.AllowSkip) where TU : struct, IEquatable, IFormattable { + // TODO: in v4 update this method to replace TU with T (consistent with Matrix, see MapConvert) Storage.MapTo(result.Storage, f, zeros, zeros == Zeros.Include ? ExistingData.AssumeZeros : ExistingData.Clear); } @@ -402,6 +403,30 @@ namespace MathNet.Numerics.LinearAlgebra /// public void MapIndexed(Func f, Vector result, Zeros zeros = Zeros.AllowSkip) where TU : struct, IEquatable, IFormattable + { + // TODO: in v4 update this method to replace TU with T (consistent with Matrix, see MapIndexedConvert) + Storage.MapIndexedTo(result.Storage, f, zeros, zeros == Zeros.Include ? ExistingData.AssumeZeros : ExistingData.Clear); + } + + /// + /// Applies a function to each value of this vector and replaces the value in the result vector. + /// If forceMapZero is not set to true, zero values may or may not be skipped depending + /// on the actual data storage implementation (relevant mostly for sparse vectors). + /// + public void MapConvert(Func f, Vector result, Zeros zeros = Zeros.AllowSkip) + where TU : struct, IEquatable, IFormattable + { + Storage.MapTo(result.Storage, f, zeros, zeros == Zeros.Include ? ExistingData.AssumeZeros : ExistingData.Clear); + } + + /// + /// Applies a function to each value of this vector and replaces the value in the result vector. + /// The index of each value (zero-based) is passed as first argument to the function. + /// If forceMapZero is not set to true, zero values may or may not be skipped depending + /// on the actual data storage implementation (relevant mostly for sparse vectors). + /// + public void MapIndexedConvert(Func f, Vector result, Zeros zeros = Zeros.AllowSkip) + where TU : struct, IEquatable, IFormattable { Storage.MapIndexedTo(result.Storage, f, zeros, zeros == Zeros.Include ? ExistingData.AssumeZeros : ExistingData.Clear); }