1

我正在尝试学习 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

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

4

1 回答 1

3

仔细阅读:

尽管 Math.NET Numerics 的核心是用 C# 编写的,但它也旨在支持 F#。为了实现这一点,我们建议在 MathNet.Numerics 之外参考 MathNet.Numerics.FSharp 包,它添加了一些模块以使其更符合习惯并包括任意精度类型(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

关联:

https://dotnetfiddle.net/6NSti7

于 2016-02-20T15:14:37.380 回答