
Hi,
it would be great if I could have an example of how foldColumns can be used e.g. for summing over columns?
In general, is there some documentation source with examples? I am really new in math.net numerics and C# in general.
Many thanks
Ioannis


Coordinator
Jun 10, 2014 at 2:06 PM
Edited Jun 10, 2014 at 2:08 PM

Note that FoldColumns folds over the columns themselves (each of them, individually), not over the column vectors. We should probably add the later as well.
Compute column sums with FoldColumns:
var m = Matrix<double>.Build.Random(4,4);
var columnSums = m.FoldColumns((sum, x) => sum+x, 0.0, Zeros.AllowSkip);
var rowSums = m.FoldRows((sum, x) => sum+x, 0.0, Zeros.AllowSkip);
Thanks,
Christoph


Coordinator
Jun 10, 2014 at 2:12 PM

PS: let me know if you have an idea for better naming, to avoid confusing folding over column vectors v.s. folding over the values of each column.



Thanks.
So in the function inside FoldColumns the only thing you have access to is a single cell value at a time.
Given that you keep FoldColumns as it is, perhaps FoldByColumns, FoldColumnsList, FoldColumnsSet, ApplyByColumns, ...


Coordinator
Jun 10, 2014 at 5:33 PM
Edited Jun 10, 2014 at 5:58 PM

Yes, exactly (and the state).
FoldColumns has just been added in v3.0.0beta02, so we can still change it until v3 is released. What about the following naming?
 FoldByColumn: renamed from FoldColumns; for each column, folds over the column values (lambda operates on values); result is effectively a row vector.
 FoldColumns: folds over all column vectors (lambda operates on vectors); result is effectively a column vector.



The proposed naming sounds good to me.
Thanks

