I'm trying to learn F#, and to create a matrix I follow the instructions from here: 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. 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).
So, you have to add a reference to 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:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.