Browse Source

LA: make non-arithmetic instance members available as functions in F#

provider
Christoph Ruegg 13 years ago
parent
commit
38fea05dcf
  1. 23
      src/FSharp/LinearAlgebra.Matrix.fs
  2. 18
      src/FSharp/LinearAlgebra.Vector.fs

23
src/FSharp/LinearAlgebra.Matrix.fs

@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics // http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com // http://mathnetnumerics.codeplex.com
// //
// Copyright (c) 2009-2013 Math.NET // Copyright (c) 2009-2014 Math.NET
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
@ -316,7 +316,6 @@ module Matrix =
let inline subInPlace (v: #Matrix<_>) (w: #Matrix<_>) = v.Subtract(w, v) let inline subInPlace (v: #Matrix<_>) (w: #Matrix<_>) = v.Subtract(w, v)
/// Returns the sum of all elements of a matrix. /// Returns the sum of all elements of a matrix.
let inline sum (A: #Matrix<'a>) = A |> foldSkipZeros (+) Matrix<'a>.Zero let inline sum (A: #Matrix<'a>) = A |> foldSkipZeros (+) Matrix<'a>.Zero
@ -329,6 +328,26 @@ module Matrix =
A.EnumerateRowsIndexed() |> Seq.map (fun (i,row) -> f i row) |> Seq.reduce (+) A.EnumerateRowsIndexed() |> Seq.map (fun (i,row) -> f i row) |> Seq.reduce (+)
let inline rowCount (A: #Matrix<_>) = A.RowCount
let inline columnCount (A: #Matrix<_>) = A.ColumnCount
let inline transpose (A: #Matrix<_>) = A.Transpose()
let inline conjugate (A: #Matrix<_>) = A.Conjugate()
let inline conjugateTranspose (A: #Matrix<_>) = A.ConjugateTranspose()
let inline inverse (A: #Matrix<_>) = A.Inverse()
let inline norm (A: #Matrix<_>) = A.L2Norm()
let inline frobenius (A: #Matrix<_>) = A.FrobeniusNorm()
let inline rank (A: #Matrix<_>) = A.Rank()
let inline trace (A: #Matrix<_>) = A.Trace()
let inline determinant (A: #Matrix<_>) = A.Determinant()
let inline condition (A: #Matrix<_>) = A.ConditionNumber()
let inline nullity (A: #Matrix<_>) = A.Nullity()
let inline kernel (A: #Matrix<_>) = A.Kernel()
let inline range (A: #Matrix<_>) = A.Range()
let inline symmetric (A: #Matrix<_>) = A.IsSymmetric
/// A module which helps constructing generic dense matrices. /// A module which helps constructing generic dense matrices.
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>] [<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]

18
src/FSharp/LinearAlgebra.Vector.fs

@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics // http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com // http://mathnetnumerics.codeplex.com
// //
// Copyright (c) 2009-2013 Math.NET // Copyright (c) 2009-2014 Math.NET
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
@ -203,6 +203,22 @@ module Vector =
let inline subInPlace (v: #Vector<_>) (w: #Vector<_>) = v.Subtract(w, v) let inline subInPlace (v: #Vector<_>) (w: #Vector<_>) = v.Subtract(w, v)
let inline length (A: #Vector<_>) = A.Count
let inline conjugate (A: #Vector<_>) = A.Conjugate()
let inline norm (A: #Vector<_>) = A.L2Norm()
let inline sum (A: #Vector<_>) = A.Sum()
let inline min (A: #Vector<_>) = A.Minimum()
let inline max (A: #Vector<_>) = A.Maximum()
let inline minIndex (A: #Vector<_>) = A.MinimumIndex()
let inline maxIndex (A: #Vector<_>) = A.MaximumIndex()
let inline minAbs (A: #Vector<_>) = A.AbsoluteMinimum()
let inline maxAbs (A: #Vector<_>) = A.AbsoluteMaximum()
let inline minAbsIndex (A: #Vector<_>) = A.AbsoluteMinimumIndex()
let inline maxAbsIndex (A: #Vector<_>) = A.AbsoluteMaximumIndex()
/// A module which helps constructing generic dense vectors. /// A module which helps constructing generic dense vectors.
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>] [<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]

Loading…
Cancel
Save