From be88393619c9d0cf7db440f0c3ee2210ba342d5c Mon Sep 17 00:00:00 2001 From: Gustavo Guerra Date: Thu, 20 Oct 2011 22:39:52 +0100 Subject: [PATCH] generalize sumColsBy and sumRowsBy so they are not bound to floats --- src/FSharp/Matrix.fs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/FSharp/Matrix.fs b/src/FSharp/Matrix.fs index 58a6e8a1..5a0d6f60 100644 --- a/src/FSharp/Matrix.fs +++ b/src/FSharp/Matrix.fs @@ -161,12 +161,12 @@ module Matrix = f /// Returns the sum of the results generated by applying the function to each column of the matrix. - let inline sumColsBy (f: int -> Vector -> float) (A: #Matrix) = - mapCols f A |> Seq.fold (+) 0.0 + let inline sumColsBy (f: int -> Vector -> 'a) (A: #Matrix) = + mapCols f A |> Seq.reduce (+) /// Returns the sum of the results generated by applying the function to each row of the matrix. - let inline sumRowsBy (f: int -> Vector -> float) (A: #Matrix) = - mapRows f A |> Seq.fold (+) 0.0 + let inline sumRowsBy (f: int -> Vector -> 'a) (A: #Matrix) = + mapRows f A |> Seq.reduce (+) /// Iterates over all elements of a matrix. let inline iter (f: float -> unit) (A: #Matrix) =