-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMathNetExtensions.fs
More file actions
29 lines (20 loc) · 865 Bytes
/
MathNetExtensions.fs
File metadata and controls
29 lines (20 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
namespace MathNet.Numerics.LinearAlgebra
open MathNet.Numerics.LinearAlgebra
[<AutoOpen>]
module VectorOperators =
let inline (.^) (v: #Vector<float>) exp =
Vector.map (fun x -> x ** exp) v
let inline (./) (v: #Vector<float>) divider =
v.PointwiseDivide(divider)
let inline (.*) (v: #Vector<float>) divider =
v.PointwiseMultiply(divider)
let inline (.-) (scalar: float) (v: #Vector<float>) =
DenseVector.init v.Count (fun i -> scalar - v.[i])
module Vector =
let inline length (v: #Vector<float>) = v.Count
let inline Σ (v: #Vector<float>) = v.Sum()
module Matrix =
let inline rowCount (m: #Matrix<float>) = m.RowCount
let inline columnCount (m: #Matrix<float>) = m.ColumnCount
let inline Σrows f A = Matrix.sumRowsBy f A
let inline Σcols f A = Matrix.sumColsBy f A