From 8d19348662ecdf9ef5218ac337e6509e078f839e Mon Sep 17 00:00:00 2001 From: Christoph Ruegg Date: Sun, 15 Jun 2014 22:22:26 +0200 Subject: [PATCH] LA: rename Matrix.FoldRows to FoldByRow; FoldColumns to FoldByColumn --- src/Numerics/LinearAlgebra/Complex/Matrix.cs | 16 ++++++++-------- src/Numerics/LinearAlgebra/Complex32/Matrix.cs | 16 ++++++++-------- src/Numerics/LinearAlgebra/Double/Matrix.cs | 16 ++++++++-------- src/Numerics/LinearAlgebra/Matrix.cs | 8 ++++---- src/Numerics/LinearAlgebra/Single/Matrix.cs | 16 ++++++++-------- .../Storage/DenseColumnMajorMatrixStorage.cs | 4 ++-- .../Storage/DiagonalMatrixStorage.cs | 4 ++-- .../LinearAlgebra/Storage/MatrixStorage.cs | 12 ++++++------ .../Storage/SparseCompressedRowMatrixStorage.cs | 4 ++-- .../MatrixStructureTheory.Functional.cs | 12 ++++++------ 10 files changed, 54 insertions(+), 54 deletions(-) diff --git a/src/Numerics/LinearAlgebra/Complex/Matrix.cs b/src/Numerics/LinearAlgebra/Complex/Matrix.cs index 2c508211..c62b9c01 100644 --- a/src/Numerics/LinearAlgebra/Complex/Matrix.cs +++ b/src/Numerics/LinearAlgebra/Complex/Matrix.cs @@ -120,20 +120,20 @@ namespace MathNet.Numerics.LinearAlgebra.Complex var ret = Vector.Build.Dense(RowCount); if (norm == 2.0) { - Storage.FoldRowsUnchecked(ret.Storage, (s, x) => s + x.MagnitudeSquared(), (x, c) => Math.Sqrt(x), ret.Storage, Zeros.AllowSkip); + Storage.FoldByRowUnchecked(ret.Storage, (s, x) => s + x.MagnitudeSquared(), (x, c) => Math.Sqrt(x), ret.Storage, Zeros.AllowSkip); } else if (norm == 1.0) { - Storage.FoldRowsUnchecked(ret.Storage, (s, x) => s + x.Magnitude, (x, c) => x, ret.Storage, Zeros.AllowSkip); + Storage.FoldByRowUnchecked(ret.Storage, (s, x) => s + x.Magnitude, (x, c) => x, ret.Storage, Zeros.AllowSkip); } else if (double.IsPositiveInfinity(norm)) { - Storage.FoldRowsUnchecked(ret.Storage, (s, x) => Math.Max(s, x.Magnitude), (x, c) => x, ret.Storage, Zeros.AllowSkip); + Storage.FoldByRowUnchecked(ret.Storage, (s, x) => Math.Max(s, x.Magnitude), (x, c) => x, ret.Storage, Zeros.AllowSkip); } else { double invnorm = 1.0/norm; - Storage.FoldRowsUnchecked(ret.Storage, (s, x) => s + Math.Pow(x.Magnitude, norm), (x, c) => Math.Pow(x, invnorm), ret.Storage, Zeros.AllowSkip); + Storage.FoldByRowUnchecked(ret.Storage, (s, x) => s + Math.Pow(x.Magnitude, norm), (x, c) => Math.Pow(x, invnorm), ret.Storage, Zeros.AllowSkip); } return ret; } @@ -152,20 +152,20 @@ namespace MathNet.Numerics.LinearAlgebra.Complex var ret = Vector.Build.Dense(ColumnCount); if (norm == 2.0) { - Storage.FoldColumnsUnchecked(ret.Storage, (s, x) => s + x.MagnitudeSquared(), (x, c) => Math.Sqrt(x), ret.Storage, Zeros.AllowSkip); + Storage.FoldByColumnUnchecked(ret.Storage, (s, x) => s + x.MagnitudeSquared(), (x, c) => Math.Sqrt(x), ret.Storage, Zeros.AllowSkip); } else if (norm == 1.0) { - Storage.FoldColumnsUnchecked(ret.Storage, (s, x) => s + x.Magnitude, (x, c) => x, ret.Storage, Zeros.AllowSkip); + Storage.FoldByColumnUnchecked(ret.Storage, (s, x) => s + x.Magnitude, (x, c) => x, ret.Storage, Zeros.AllowSkip); } else if (double.IsPositiveInfinity(norm)) { - Storage.FoldColumnsUnchecked(ret.Storage, (s, x) => Math.Max(s, x.Magnitude), (x, c) => x, ret.Storage, Zeros.AllowSkip); + Storage.FoldByColumnUnchecked(ret.Storage, (s, x) => Math.Max(s, x.Magnitude), (x, c) => x, ret.Storage, Zeros.AllowSkip); } else { double invnorm = 1.0/norm; - Storage.FoldColumnsUnchecked(ret.Storage, (s, x) => s + Math.Pow(x.Magnitude, norm), (x, c) => Math.Pow(x, invnorm), ret.Storage, Zeros.AllowSkip); + Storage.FoldByColumnUnchecked(ret.Storage, (s, x) => s + Math.Pow(x.Magnitude, norm), (x, c) => Math.Pow(x, invnorm), ret.Storage, Zeros.AllowSkip); } return ret; } diff --git a/src/Numerics/LinearAlgebra/Complex32/Matrix.cs b/src/Numerics/LinearAlgebra/Complex32/Matrix.cs index 79451d43..1f1d0042 100644 --- a/src/Numerics/LinearAlgebra/Complex32/Matrix.cs +++ b/src/Numerics/LinearAlgebra/Complex32/Matrix.cs @@ -114,20 +114,20 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 var ret = Vector.Build.Dense(RowCount); if (norm == 2.0) { - Storage.FoldRowsUnchecked(ret.Storage, (s, x) => s + x.MagnitudeSquared, (x, c) => Math.Sqrt(x), ret.Storage, Zeros.AllowSkip); + Storage.FoldByRowUnchecked(ret.Storage, (s, x) => s + x.MagnitudeSquared, (x, c) => Math.Sqrt(x), ret.Storage, Zeros.AllowSkip); } else if (norm == 1.0) { - Storage.FoldRowsUnchecked(ret.Storage, (s, x) => s + x.Magnitude, (x, c) => x, ret.Storage, Zeros.AllowSkip); + Storage.FoldByRowUnchecked(ret.Storage, (s, x) => s + x.Magnitude, (x, c) => x, ret.Storage, Zeros.AllowSkip); } else if (double.IsPositiveInfinity(norm)) { - Storage.FoldRowsUnchecked(ret.Storage, (s, x) => Math.Max(s, x.Magnitude), (x, c) => x, ret.Storage, Zeros.AllowSkip); + Storage.FoldByRowUnchecked(ret.Storage, (s, x) => Math.Max(s, x.Magnitude), (x, c) => x, ret.Storage, Zeros.AllowSkip); } else { double invnorm = 1.0/norm; - Storage.FoldRowsUnchecked(ret.Storage, (s, x) => s + Math.Pow(x.Magnitude, norm), (x, c) => Math.Pow(x, invnorm), ret.Storage, Zeros.AllowSkip); + Storage.FoldByRowUnchecked(ret.Storage, (s, x) => s + Math.Pow(x.Magnitude, norm), (x, c) => Math.Pow(x, invnorm), ret.Storage, Zeros.AllowSkip); } return ret; } @@ -146,20 +146,20 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 var ret = Vector.Build.Dense(ColumnCount); if (norm == 2.0) { - Storage.FoldColumnsUnchecked(ret.Storage, (s, x) => s + x.MagnitudeSquared, (x, c) => Math.Sqrt(x), ret.Storage, Zeros.AllowSkip); + Storage.FoldByColumnUnchecked(ret.Storage, (s, x) => s + x.MagnitudeSquared, (x, c) => Math.Sqrt(x), ret.Storage, Zeros.AllowSkip); } else if (norm == 1.0) { - Storage.FoldColumnsUnchecked(ret.Storage, (s, x) => s + x.Magnitude, (x, c) => x, ret.Storage, Zeros.AllowSkip); + Storage.FoldByColumnUnchecked(ret.Storage, (s, x) => s + x.Magnitude, (x, c) => x, ret.Storage, Zeros.AllowSkip); } else if (double.IsPositiveInfinity(norm)) { - Storage.FoldColumnsUnchecked(ret.Storage, (s, x) => Math.Max(s, x.Magnitude), (x, c) => x, ret.Storage, Zeros.AllowSkip); + Storage.FoldByColumnUnchecked(ret.Storage, (s, x) => Math.Max(s, x.Magnitude), (x, c) => x, ret.Storage, Zeros.AllowSkip); } else { double invnorm = 1.0/norm; - Storage.FoldColumnsUnchecked(ret.Storage, (s, x) => s + Math.Pow(x.Magnitude, norm), (x, c) => Math.Pow(x, invnorm), ret.Storage, Zeros.AllowSkip); + Storage.FoldByColumnUnchecked(ret.Storage, (s, x) => s + Math.Pow(x.Magnitude, norm), (x, c) => Math.Pow(x, invnorm), ret.Storage, Zeros.AllowSkip); } return ret; } diff --git a/src/Numerics/LinearAlgebra/Double/Matrix.cs b/src/Numerics/LinearAlgebra/Double/Matrix.cs index b4a772c0..aac56517 100644 --- a/src/Numerics/LinearAlgebra/Double/Matrix.cs +++ b/src/Numerics/LinearAlgebra/Double/Matrix.cs @@ -112,20 +112,20 @@ namespace MathNet.Numerics.LinearAlgebra.Double var ret = Vector.Build.Dense(RowCount); if (norm == 2.0) { - Storage.FoldRowsUnchecked(ret.Storage, (s, x) => s + x*x, (x, c) => Math.Sqrt(x), ret.Storage, Zeros.AllowSkip); + Storage.FoldByRowUnchecked(ret.Storage, (s, x) => s + x*x, (x, c) => Math.Sqrt(x), ret.Storage, Zeros.AllowSkip); } else if (norm == 1.0) { - Storage.FoldRowsUnchecked(ret.Storage, (s, x) => s + Math.Abs(x), (x, c) => x, ret.Storage, Zeros.AllowSkip); + Storage.FoldByRowUnchecked(ret.Storage, (s, x) => s + Math.Abs(x), (x, c) => x, ret.Storage, Zeros.AllowSkip); } else if (double.IsPositiveInfinity(norm)) { - Storage.FoldRowsUnchecked(ret.Storage, (s, x) => Math.Max(s, Math.Abs(x)), (x, c) => x, ret.Storage, Zeros.AllowSkip); + Storage.FoldByRowUnchecked(ret.Storage, (s, x) => Math.Max(s, Math.Abs(x)), (x, c) => x, ret.Storage, Zeros.AllowSkip); } else { double invnorm = 1.0/norm; - Storage.FoldRowsUnchecked(ret.Storage, (s, x) => s + Math.Pow(Math.Abs(x), norm), (x, c) => Math.Pow(x, invnorm), ret.Storage, Zeros.AllowSkip); + Storage.FoldByRowUnchecked(ret.Storage, (s, x) => s + Math.Pow(Math.Abs(x), norm), (x, c) => Math.Pow(x, invnorm), ret.Storage, Zeros.AllowSkip); } return ret; } @@ -144,20 +144,20 @@ namespace MathNet.Numerics.LinearAlgebra.Double var ret = Vector.Build.Dense(ColumnCount); if (norm == 2.0) { - Storage.FoldColumnsUnchecked(ret.Storage, (s, x) => s + x*x, (x, c) => Math.Sqrt(x), ret.Storage, Zeros.AllowSkip); + Storage.FoldByColumnUnchecked(ret.Storage, (s, x) => s + x*x, (x, c) => Math.Sqrt(x), ret.Storage, Zeros.AllowSkip); } else if (norm == 1.0) { - Storage.FoldColumnsUnchecked(ret.Storage, (s, x) => s + Math.Abs(x), (x, c) => x, ret.Storage, Zeros.AllowSkip); + Storage.FoldByColumnUnchecked(ret.Storage, (s, x) => s + Math.Abs(x), (x, c) => x, ret.Storage, Zeros.AllowSkip); } else if (double.IsPositiveInfinity(norm)) { - Storage.FoldColumnsUnchecked(ret.Storage, (s, x) => Math.Max(s, Math.Abs(x)), (x, c) => x, ret.Storage, Zeros.AllowSkip); + Storage.FoldByColumnUnchecked(ret.Storage, (s, x) => Math.Max(s, Math.Abs(x)), (x, c) => x, ret.Storage, Zeros.AllowSkip); } else { double invnorm = 1.0/norm; - Storage.FoldColumnsUnchecked(ret.Storage, (s, x) => s + Math.Pow(Math.Abs(x), norm), (x, c) => Math.Pow(x, invnorm), ret.Storage, Zeros.AllowSkip); + Storage.FoldByColumnUnchecked(ret.Storage, (s, x) => s + Math.Pow(Math.Abs(x), norm), (x, c) => Math.Pow(x, invnorm), ret.Storage, Zeros.AllowSkip); } return ret; } diff --git a/src/Numerics/LinearAlgebra/Matrix.cs b/src/Numerics/LinearAlgebra/Matrix.cs index 680d83e4..f2acc287 100644 --- a/src/Numerics/LinearAlgebra/Matrix.cs +++ b/src/Numerics/LinearAlgebra/Matrix.cs @@ -1579,11 +1579,11 @@ namespace MathNet.Numerics.LinearAlgebra /// For each row, applies a function f to each element of the row, threading an accumulator argument through the computation. /// Returns a vector with the resulting accumulator states for each row. /// - public Vector FoldRows(Func f, TU state, Zeros zeros = Zeros.AllowSkip) + public Vector FoldByRow(Func f, TU state, Zeros zeros = Zeros.AllowSkip) where TU : struct, IEquatable, IFormattable { var result = Vector.Build.SameAs(this, RowCount); - Storage.FoldRowsUnchecked(result.Storage, f, (x, c) => x, DenseVectorStorage.OfInit(RowCount, i => state), zeros); + Storage.FoldByRowUnchecked(result.Storage, f, (x, c) => x, DenseVectorStorage.OfInit(RowCount, i => state), zeros); return result; } @@ -1591,11 +1591,11 @@ namespace MathNet.Numerics.LinearAlgebra /// For each column, applies a function f to each element of the column, threading an accumulator argument through the computation. /// Returns a vector with the resulting accumulator states for each column. /// - public Vector FoldColumns(Func f, TU state, Zeros zeros = Zeros.AllowSkip) + public Vector FoldByColumn(Func f, TU state, Zeros zeros = Zeros.AllowSkip) where TU : struct, IEquatable, IFormattable { var result = Vector.Build.SameAs(this, ColumnCount); - Storage.FoldColumnsUnchecked(result.Storage, f, (x, c) => x, DenseVectorStorage.OfInit(ColumnCount, i => state), zeros); + Storage.FoldByColumnUnchecked(result.Storage, f, (x, c) => x, DenseVectorStorage.OfInit(ColumnCount, i => state), zeros); return result; } } diff --git a/src/Numerics/LinearAlgebra/Single/Matrix.cs b/src/Numerics/LinearAlgebra/Single/Matrix.cs index 69ebdb00..20a6dd69 100644 --- a/src/Numerics/LinearAlgebra/Single/Matrix.cs +++ b/src/Numerics/LinearAlgebra/Single/Matrix.cs @@ -112,20 +112,20 @@ namespace MathNet.Numerics.LinearAlgebra.Single var ret = Vector.Build.Dense(RowCount); if (norm == 2.0) { - Storage.FoldRowsUnchecked(ret.Storage, (s, x) => s + x*x, (x, c) => Math.Sqrt(x), ret.Storage, Zeros.AllowSkip); + Storage.FoldByRowUnchecked(ret.Storage, (s, x) => s + x*x, (x, c) => Math.Sqrt(x), ret.Storage, Zeros.AllowSkip); } else if (norm == 1.0) { - Storage.FoldRowsUnchecked(ret.Storage, (s, x) => s + Math.Abs(x), (x, c) => x, ret.Storage, Zeros.AllowSkip); + Storage.FoldByRowUnchecked(ret.Storage, (s, x) => s + Math.Abs(x), (x, c) => x, ret.Storage, Zeros.AllowSkip); } else if (double.IsPositiveInfinity(norm)) { - Storage.FoldRowsUnchecked(ret.Storage, (s, x) => Math.Max(s, Math.Abs(x)), (x, c) => x, ret.Storage, Zeros.AllowSkip); + Storage.FoldByRowUnchecked(ret.Storage, (s, x) => Math.Max(s, Math.Abs(x)), (x, c) => x, ret.Storage, Zeros.AllowSkip); } else { double invnorm = 1.0/norm; - Storage.FoldRowsUnchecked(ret.Storage, (s, x) => s + Math.Pow(Math.Abs(x), norm), (x, c) => Math.Pow(x, invnorm), ret.Storage, Zeros.AllowSkip); + Storage.FoldByRowUnchecked(ret.Storage, (s, x) => s + Math.Pow(Math.Abs(x), norm), (x, c) => Math.Pow(x, invnorm), ret.Storage, Zeros.AllowSkip); } return ret; } @@ -144,20 +144,20 @@ namespace MathNet.Numerics.LinearAlgebra.Single var ret = Vector.Build.Dense(ColumnCount); if (norm == 2.0) { - Storage.FoldColumnsUnchecked(ret.Storage, (s, x) => s + x*x, (x, c) => Math.Sqrt(x), ret.Storage, Zeros.AllowSkip); + Storage.FoldByColumnUnchecked(ret.Storage, (s, x) => s + x*x, (x, c) => Math.Sqrt(x), ret.Storage, Zeros.AllowSkip); } else if (norm == 1.0) { - Storage.FoldColumnsUnchecked(ret.Storage, (s, x) => s + Math.Abs(x), (x, c) => x, ret.Storage, Zeros.AllowSkip); + Storage.FoldByColumnUnchecked(ret.Storage, (s, x) => s + Math.Abs(x), (x, c) => x, ret.Storage, Zeros.AllowSkip); } else if (double.IsPositiveInfinity(norm)) { - Storage.FoldColumnsUnchecked(ret.Storage, (s, x) => Math.Max(s, Math.Abs(x)), (x, c) => x, ret.Storage, Zeros.AllowSkip); + Storage.FoldByColumnUnchecked(ret.Storage, (s, x) => Math.Max(s, Math.Abs(x)), (x, c) => x, ret.Storage, Zeros.AllowSkip); } else { double invnorm = 1.0/norm; - Storage.FoldColumnsUnchecked(ret.Storage, (s, x) => s + Math.Pow(Math.Abs(x), norm), (x, c) => Math.Pow(x, invnorm), ret.Storage, Zeros.AllowSkip); + Storage.FoldByColumnUnchecked(ret.Storage, (s, x) => s + Math.Pow(Math.Abs(x), norm), (x, c) => Math.Pow(x, invnorm), ret.Storage, Zeros.AllowSkip); } return ret; } diff --git a/src/Numerics/LinearAlgebra/Storage/DenseColumnMajorMatrixStorage.cs b/src/Numerics/LinearAlgebra/Storage/DenseColumnMajorMatrixStorage.cs index c68c8e21..ceef2500 100644 --- a/src/Numerics/LinearAlgebra/Storage/DenseColumnMajorMatrixStorage.cs +++ b/src/Numerics/LinearAlgebra/Storage/DenseColumnMajorMatrixStorage.cs @@ -727,7 +727,7 @@ namespace MathNet.Numerics.LinearAlgebra.Storage // FUNCTIONAL COMBINATORS: FOLD - internal override void FoldRowsUnchecked(VectorStorage target, Func f, Func finalize, VectorStorage state, Zeros zeros = Zeros.AllowSkip) + internal override void FoldByRowUnchecked(VectorStorage target, Func f, Func finalize, VectorStorage state, Zeros zeros = Zeros.AllowSkip) { for (int i = 0; i < RowCount; i++) { @@ -740,7 +740,7 @@ namespace MathNet.Numerics.LinearAlgebra.Storage } } - internal override void FoldColumnsUnchecked(VectorStorage target, Func f, Func finalize, VectorStorage state, Zeros zeros = Zeros.AllowSkip) + internal override void FoldByColumnUnchecked(VectorStorage target, Func f, Func finalize, VectorStorage state, Zeros zeros = Zeros.AllowSkip) { for (int j = 0; j < ColumnCount; j++) { diff --git a/src/Numerics/LinearAlgebra/Storage/DiagonalMatrixStorage.cs b/src/Numerics/LinearAlgebra/Storage/DiagonalMatrixStorage.cs index d0d47290..810b1d7d 100644 --- a/src/Numerics/LinearAlgebra/Storage/DiagonalMatrixStorage.cs +++ b/src/Numerics/LinearAlgebra/Storage/DiagonalMatrixStorage.cs @@ -901,7 +901,7 @@ namespace MathNet.Numerics.LinearAlgebra.Storage // FUNCTIONAL COMBINATORS: FOLD - internal override void FoldRowsUnchecked(VectorStorage target, Func f, Func finalize, VectorStorage state, Zeros zeros = Zeros.AllowSkip) + internal override void FoldByRowUnchecked(VectorStorage target, Func f, Func finalize, VectorStorage state, Zeros zeros = Zeros.AllowSkip) { if (zeros == Zeros.AllowSkip) { @@ -929,7 +929,7 @@ namespace MathNet.Numerics.LinearAlgebra.Storage } } - internal override void FoldColumnsUnchecked(VectorStorage target, Func f, Func finalize, VectorStorage state, Zeros zeros = Zeros.AllowSkip) + internal override void FoldByColumnUnchecked(VectorStorage target, Func f, Func finalize, VectorStorage state, Zeros zeros = Zeros.AllowSkip) { if (zeros == Zeros.AllowSkip) { diff --git a/src/Numerics/LinearAlgebra/Storage/MatrixStorage.cs b/src/Numerics/LinearAlgebra/Storage/MatrixStorage.cs index 0cf4a15f..ab55d2d9 100644 --- a/src/Numerics/LinearAlgebra/Storage/MatrixStorage.cs +++ b/src/Numerics/LinearAlgebra/Storage/MatrixStorage.cs @@ -670,7 +670,7 @@ namespace MathNet.Numerics.LinearAlgebra.Storage // FUNCTIONAL COMBINATORS: FOLD - public void FoldRows(VectorStorage target, Func f, Func finalize, VectorStorage state, Zeros zeros = Zeros.AllowSkip) + public void FoldByRow(VectorStorage target, Func f, Func finalize, VectorStorage state, Zeros zeros = Zeros.AllowSkip) where TU : struct, IEquatable, IFormattable { if (target == null) @@ -691,10 +691,10 @@ namespace MathNet.Numerics.LinearAlgebra.Storage throw new ArgumentException(Resources.ArgumentVectorsSameLength, "state"); } - FoldRowsUnchecked(target, f, finalize, state, zeros); + FoldByRowUnchecked(target, f, finalize, state, zeros); } - internal virtual void FoldRowsUnchecked(VectorStorage target, Func f, Func finalize, VectorStorage state, Zeros zeros = Zeros.AllowSkip) + internal virtual void FoldByRowUnchecked(VectorStorage target, Func f, Func finalize, VectorStorage state, Zeros zeros = Zeros.AllowSkip) where TU : struct, IEquatable, IFormattable { for (int i = 0; i < RowCount; i++) @@ -708,7 +708,7 @@ namespace MathNet.Numerics.LinearAlgebra.Storage } } - public void FoldColumns(VectorStorage target, Func f, Func finalize, VectorStorage state, Zeros zeros = Zeros.AllowSkip) + public void FoldByColumn(VectorStorage target, Func f, Func finalize, VectorStorage state, Zeros zeros = Zeros.AllowSkip) where TU : struct, IEquatable, IFormattable { if (target == null) @@ -729,10 +729,10 @@ namespace MathNet.Numerics.LinearAlgebra.Storage throw new ArgumentException(Resources.ArgumentVectorsSameLength, "state"); } - FoldColumnsUnchecked(target, f, finalize, state, zeros); + FoldByColumnUnchecked(target, f, finalize, state, zeros); } - internal virtual void FoldColumnsUnchecked(VectorStorage target, Func f, Func finalize, VectorStorage state, Zeros zeros = Zeros.AllowSkip) + internal virtual void FoldByColumnUnchecked(VectorStorage target, Func f, Func finalize, VectorStorage state, Zeros zeros = Zeros.AllowSkip) where TU : struct, IEquatable, IFormattable { for (int j = 0; j < ColumnCount; j++) diff --git a/src/Numerics/LinearAlgebra/Storage/SparseCompressedRowMatrixStorage.cs b/src/Numerics/LinearAlgebra/Storage/SparseCompressedRowMatrixStorage.cs index f1ed149a..084664fc 100644 --- a/src/Numerics/LinearAlgebra/Storage/SparseCompressedRowMatrixStorage.cs +++ b/src/Numerics/LinearAlgebra/Storage/SparseCompressedRowMatrixStorage.cs @@ -1757,7 +1757,7 @@ namespace MathNet.Numerics.LinearAlgebra.Storage // FUNCTIONAL COMBINATORS: FOLD - internal override void FoldRowsUnchecked(VectorStorage target, Func f, Func finalize, VectorStorage state, Zeros zeros = Zeros.AllowSkip) + internal override void FoldByRowUnchecked(VectorStorage target, Func f, Func finalize, VectorStorage state, Zeros zeros = Zeros.AllowSkip) { if (zeros == Zeros.AllowSkip) { @@ -1797,7 +1797,7 @@ namespace MathNet.Numerics.LinearAlgebra.Storage } } - internal override void FoldColumnsUnchecked(VectorStorage target, Func f, Func finalize, VectorStorage state, Zeros zeros = Zeros.AllowSkip) + internal override void FoldByColumnUnchecked(VectorStorage target, Func f, Func finalize, VectorStorage state, Zeros zeros = Zeros.AllowSkip) { var denseResult = target as DenseVectorStorage ?? new DenseVectorStorage(ColumnCount); diff --git a/src/UnitTests/LinearAlgebraTests/MatrixStructureTheory.Functional.cs b/src/UnitTests/LinearAlgebraTests/MatrixStructureTheory.Functional.cs index 73e9a732..b1fb70eb 100644 --- a/src/UnitTests/LinearAlgebraTests/MatrixStructureTheory.Functional.cs +++ b/src/UnitTests/LinearAlgebraTests/MatrixStructureTheory.Functional.cs @@ -261,20 +261,20 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests public void CanFoldRows(Matrix matrix) { // not forced - var rowSum = matrix.FoldRows((s, x) => Operator.Add(s, x), Operator.Zero, Zeros.AllowSkip); + var rowSum = matrix.FoldByRow((s, x) => Operator.Add(s, x), Operator.Zero, Zeros.AllowSkip); for (int i = 0; i < rowSum.Count; i++) { Assert.That(rowSum.At(i), Is.EqualTo(matrix.Row(i).Enumerate().Aggregate((a, b) => Operator.Add(a, b))), "not forced"); } // forced - rowSum = matrix.FoldRows((s, x) => Operator.Add(s, x), Operator.Zero, Zeros.Include); + rowSum = matrix.FoldByRow((s, x) => Operator.Add(s, x), Operator.Zero, Zeros.Include); for (int i = 0; i < rowSum.Count; i++) { Assert.That(rowSum.At(i), Is.EqualTo(matrix.Row(i).Enumerate().Aggregate((a, b) => Operator.Add(a, b))), "forced"); } - Assert.That(matrix.FoldRows((s, x) => s + 1.0, 0.0, Zeros.Include), + Assert.That(matrix.FoldByRow((s, x) => s + 1.0, 0.0, Zeros.Include), Is.EqualTo(Vector.Build.Dense(matrix.RowCount, matrix.ColumnCount)), "forced - full coverage"); } @@ -282,20 +282,20 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests public void CanFoldColumns(Matrix matrix) { // not forced - var colSum = matrix.FoldColumns((s, x) => Operator.Add(s, x), Operator.Zero, Zeros.AllowSkip); + var colSum = matrix.FoldByColumn((s, x) => Operator.Add(s, x), Operator.Zero, Zeros.AllowSkip); for (int i = 0; i < colSum.Count; i++) { Assert.That(colSum.At(i), Is.EqualTo(matrix.Column(i).Enumerate().Aggregate((a, b) => Operator.Add(a, b))), "not forced"); } // forced - colSum = matrix.FoldColumns((s, x) => Operator.Add(s, x), Operator.Zero, Zeros.Include); + colSum = matrix.FoldByColumn((s, x) => Operator.Add(s, x), Operator.Zero, Zeros.Include); for (int i = 0; i < colSum.Count; i++) { Assert.That(colSum.At(i), Is.EqualTo(matrix.Column(i).Enumerate().Aggregate((a, b) => Operator.Add(a, b))), "forced"); } - Assert.That(matrix.FoldColumns((s, x) => s + 1.0, 0.0, Zeros.Include), + Assert.That(matrix.FoldByColumn((s, x) => s + 1.0, 0.0, Zeros.Include), Is.EqualTo(Vector.Build.Dense(matrix.ColumnCount, matrix.RowCount)), "forced - full coverage"); } }