简体   繁体   English

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

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

I'm trying to learn F#, and to create a matrix I follow the instructions from here: http://numerics.mathdotnet.com/ 我正在尝试学习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

Then I get this error: the value or constructor matrix is not defined 然后我得到这个错误:没有定义值或构造函数矩阵

Read carefully: 仔细阅读:

Even though the core of Math.NET Numerics is written in C#, it aims to support F# just as well. 虽然Math.NET Numerics的核心是用C#编写的,但它的目的也是为了支持F#。 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之外还引用MathNet.Numerics.FSharp包,它添加了一些模块以使其更具惯用性并包含任意精度类型(BigInteger,BigRational)。

So, you have to add a reference to MathNet.Numerics.FSharp 因此,您必须添加对MathNet.Numerics.FSharp的引用

Example: 例:

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"

Print: 打印:

DenseMatrix 2x2-Double
  2  4
2.5  7

Link: 链接:

https://dotnetfiddle.net/6NSti7 https://dotnetfiddle.net/6NSti7

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM