【问题标题】:F#: For MathNet Numerics the value or constructor matrix is not definedF#:对于 MathNet Numerics,未定义值或构造函数矩阵
【发布时间】:2016-02-20 15:08:13
【问题描述】:

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

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

【问题讨论】:

  • 你是否也在引用MathNet.Numerics.FSharp 包?

标签: .net matrix f# mathnet-numerics


【解决方案1】:

仔细阅读:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-14
    • 1970-01-01
    • 2012-03-27
    • 2017-02-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多