[英]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
然后我得到這個錯誤:沒有定義值或構造函數矩陣
仔細閱讀:
雖然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
鏈接:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.