F# Interpolation

91 Views Asked by At

I am trying to use ILNumerics from F#. It seems quite difficult.

I would like to replicate this example

What I have so far is the following code:

open ILNumerics 
open type ILMath
let inline (!) (x :RetArray<'T>) = Array<'T>.op_Implicit(x)
let inline (!!) (x:Array<'T> ) = InArray<'T>.op_Implicit(x) 
let inline  (!!!) (x:float[]) :InArray<float>  = Array.map float32 x 
                                                  |> InArray.op_Implicit

let inline (!~) (x:float[]) : Array<float> = Array.map float32 x 
                                             |> Array.op_Implicit

let vec1 = (!~) [|1.0 .. 0.1 .. 2.0 |]

let X1 =   (linspace<float>((!!!)[|-3.0|],(!!!) [|3.0|],(!!!)[|20.0|]))
            |> Seq.toArray  
            |> (!~)
            |> (!!)
            
let X2 = X1 

let X3 :OutArray<float>= null
let T = meshgrid(X1,X2, X3)

Do I really need all these conversions to make it work? Also, how do I use an interpolant? I have scattered data and have to map from R3 -> R2 and from R4 -> R3.

I was considering Kriging interpolation, but it seems quite tough to use the library from F#. Any suggestion? Otherwise will be better off to solve the problem in C# and call it from F#, when needed?

0

There are 0 best solutions below

Related Questions in F#