1

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

Guy Coder
  • 24,501
  • 8
  • 71
  • 136
Souf
  • 369
  • 2
  • 16

1 Answers1

3

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:

https://dotnetfiddle.net/6NSti7

Guy Coder
  • 24,501
  • 8
  • 71
  • 136
FoggyFinder
  • 2,230
  • 2
  • 20
  • 34