|
|
|
@ -4,7 +4,7 @@ |
|
|
|
// http://github.com/mathnet/mathnet-numerics |
|
|
|
// 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 |
|
|
|
// obtaining a copy of this software and associated documentation |
|
|
|
@ -169,13 +169,13 @@ module Matrix = |
|
|
|
|
|
|
|
/// Checks whether there is a column in the matrix that satisfies a predicate. |
|
|
|
let inline existsCol p (m: #Matrix<_>) = m.EnumerateColumns() |> Seq.exists p |
|
|
|
|
|
|
|
|
|
|
|
/// Checks whether there is a column in the matrix that satisfies a position dependent predicate. |
|
|
|
let inline existsiCol p (m: #Matrix<_>) = m.EnumerateColumnsIndexed() |> Seq.exists (fun (j,x) -> p j x) |
|
|
|
|
|
|
|
|
|
|
|
/// Checks whether there is a row in the matrix that satisfies a predicate. |
|
|
|
let inline existsRow p (m: #Matrix<_>) = m.EnumerateRows() |> Seq.exists p |
|
|
|
|
|
|
|
|
|
|
|
/// Checks whether there is a row in the matrix that satisfies a position dependent predicate. |
|
|
|
let inline existsiRow p (m: #Matrix<_>) = m.EnumerateRowsIndexed() |> Seq.exists (fun (i,x) -> p i x) |
|
|
|
|
|
|
|
@ -194,13 +194,13 @@ module Matrix = |
|
|
|
|
|
|
|
/// Checks whether all columns in the matrix that satisfy a predicate. |
|
|
|
let inline forallCols p (m: #Matrix<_>) = m.EnumerateColumns() |> Seq.forall p |
|
|
|
|
|
|
|
|
|
|
|
/// Checks whether all columns in the matrix that satisfy a position dependent predicate. |
|
|
|
let inline foralliCols p (m: #Matrix<_>) = m.EnumerateColumnsIndexed() |> Seq.forall (fun (j,x) -> p j x) |
|
|
|
|
|
|
|
|
|
|
|
/// Checks whether all rows in the matrix that satisfy a predicate. |
|
|
|
let inline forallRows p (m: #Matrix<_>) = m.EnumerateRows() |> Seq.forall p |
|
|
|
|
|
|
|
|
|
|
|
/// Checks whether all rows in the matrix that satisfy a position dependent predicate. |
|
|
|
let inline foralliRows p (m: #Matrix<_>) = m.EnumerateRowsIndexed() |> Seq.forall (fun (i,x) -> p i x) |
|
|
|
|
|
|
|
@ -316,7 +316,6 @@ module Matrix = |
|
|
|
let inline subInPlace (v: #Matrix<_>) (w: #Matrix<_>) = v.Subtract(w, v) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Returns the sum of all elements of a matrix. |
|
|
|
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 (+) |
|
|
|
|
|
|
|
|
|
|
|
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. |
|
|
|
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>] |
|
|
|
@ -349,7 +368,7 @@ module DenseMatrix = |
|
|
|
/// Create a random matrix with the given dimension and value distribution. |
|
|
|
let inline random<'T when 'T:struct and 'T :> ValueType and 'T: (new: unit ->'T) and 'T :> IEquatable<'T> and 'T :> IFormattable> |
|
|
|
(rows: int) (cols: int) (dist: IContinuousDistribution) = Matrix<'T>.Build.Random(rows, cols, dist) |
|
|
|
|
|
|
|
|
|
|
|
/// Create a random matrix with the given dimension and standard distributed values. |
|
|
|
let inline randomStandard<'T when 'T:struct and 'T :> ValueType and 'T: (new: unit ->'T) and 'T :> IEquatable<'T> and 'T :> IFormattable> |
|
|
|
(rows: int) (cols: int) = Matrix<'T>.Build.Random(rows, cols) |
|
|
|
@ -363,7 +382,7 @@ module DenseMatrix = |
|
|
|
|
|
|
|
/// Create a matrix with the given dimension and set all diagonal values to x. All other values are zero. |
|
|
|
let inline diag (order: int) (x: 'T) = Matrix<'T>.Build.DenseDiagonal(order, x) |
|
|
|
|
|
|
|
|
|
|
|
/// Create a matrix with the given dimension and set all diagonal values to x. All other values are zero. |
|
|
|
let inline diag2 (rows: int) (cols: int) (x: 'T) = Matrix<'T>.Build.DenseDiagonal(rows, cols, x) |
|
|
|
|
|
|
|
@ -458,7 +477,7 @@ module SparseMatrix = |
|
|
|
|
|
|
|
/// Create a matrix with the given dimension and set all diagonal values to x. All other values are zero. |
|
|
|
let inline diag (order: int) (x: 'T) = Matrix<'T>.Build.SparseDiagonal(order, x) |
|
|
|
|
|
|
|
|
|
|
|
/// Create a matrix with the given dimension and set all diagonal values to x. All other values are zero. |
|
|
|
let inline diag2 (rows: int) (cols: int) (x: 'T) = Matrix<'T>.Build.SparseDiagonal(rows, cols, x) |
|
|
|
|
|
|
|
|