Browse Source

generalize sumColsBy and sumRowsBy so they are not bound to floats

la-knuth
Gustavo Guerra 15 years ago
committed by Christoph Ruegg
parent
commit
be88393619
  1. 8
      src/FSharp/Matrix.fs

8
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> -> float) (A: #Matrix<float>) =
mapCols f A |> Seq.fold (+) 0.0
let inline sumColsBy (f: int -> Vector<float> -> 'a) (A: #Matrix<float>) =
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> -> float) (A: #Matrix<float>) =
mapRows f A |> Seq.fold (+) 0.0
let inline sumRowsBy (f: int -> Vector<float> -> 'a) (A: #Matrix<float>) =
mapRows f A |> Seq.reduce (+)
/// Iterates over all elements of a matrix.
let inline iter (f: float -> unit) (A: #Matrix<float>) =

Loading…
Cancel
Save