F#:对于 MathNet Numerics,未定义值或构造函数矩阵

F#: For MathNet Numerics the value or constructor matrix is not defined

我正在尝试学习 F#,并按照此处的说明创建矩阵:http://numerics.mathdotnet.com/

module Gew.M
open MathNet.Numerics
open MathNet.Numerics.LinearAlgebra


let matrix1 =   matrix [[1.0; 2.0]; [1.0; 3.0]]
let matrix2 =  matrix [[1.0; -2.0]; [0.5; 3.0]]
let matrix12 = matrix1 * matrix2

然后我得到这个错误:未定义值或构造函数矩阵

仔细阅读:

Even though the core of Math.NET Numerics is written in C#, it aims to support F# just as well. In order to achieve this we recommend to reference the MathNet.Numerics.FSharp package in addition to MathNet.Numerics, which adds a few modules to make it more idiomatic and includes arbitrary precision types (BigInteger, BigRational).

因此,您必须添加对 MathNet.Numerics.FSharp

的引用

示例:

open MathNet.Numerics.LinearAlgebra

let matrix1 =   matrix [[1.0; 2.0]; [1.0; 3.0]]
let matrix2 =  matrix [[1.0; -2.0]; [0.5; 3.0]]
let matrix12 = matrix1 * matrix2

matrix12 |> printfn "%A"

打印:

DenseMatrix 2x2-Double
  2  4
2.5  7

Link:

https://dotnetfiddle.net/6NSti7