Does ILNumerics interp2 only allow square matrix?

43 views Asked by At

I am trying to follow the sample from

https://ilnumerics.net/bigdata-array-visualizer.html

The code

Array<float> smooth = Interpolation.splinen(terrain, 
ILMath.cell(X1, X2), ILMath.cell(Xn1, Xn2));

does not compile (cannot convert from 'ILNumerics.Array' to 'ILNumerics.InArray' IlNumericsUtility) so I changed it to

///https://m.ilnumerics.net/apidoc/html/M_ILNumerics_Toolboxes_Interpolation_splinens_9.htm
            Array<float> terrain = ILMath.tosingle(SpecialData.terrain["20:40;20:45"]) + 2000;

            ///Grid position vectors for the values in V (non-/uniform), matching the 
            ///lengths of corresponding dims in V. Cell array of length N.
            Array<float> X1 = ILMath.vec<float>(20, 40);
            Array<float> X2 = ILMath.vec<float>(20, 45);

            var size = ILMath.length(terrain);
            Console.WriteLine(size);

            //// prepare grid vectors for target resolution grid 
            Array<float> Xn1 = ILMath.linspace<float>(25, 35, 100);
            Array<float> Xn2 = ILMath.linspace<float>(30, 35, 100);

            Array<float> smooth = Interpolation.splinen(terrain, 
ILMath.cell(X1, X2), ILMath.cell(Xn1, Xn2)); //<---This gives compile error

            //https://m.ilnumerics.net/apidoc/html/M_ILNumerics_Toolboxes_Interpolation_interp2.htm
            Array<float> smooth = Interpolation.interp2(terrain, X1, X2, Xn1, Xn2, 0,
            InterpolationMethod.spline);

This compiles. But we I run it I get an exception: "The length of input argument X must match the length of the working dimension in V."

When I change it all to 20,40, it works. Does that mean interp2 can only use rectangular "x/y"?

And while asking questions.. Why does the splinen way not compile?

Array<float> terrain = ILMath.tosingle(SpecialData.terrain["20:40;20:40"]) + 2000;

            ///Grid position vectors for the values in V (non-/uniform), matching the 
            ///lengths of corresponding dims in V. Cell array of length N.
            Array<float> X1 = ILMath.vec<float>(20, 40);
            Array<float> X2 = ILMath.vec<float>(20, 40);

interp2

1

There are 1 answers

0
Haymo Kutschbach On

This error message indicates that at least parts of the array type are defined in your own project. Don't do this! ILNumerics is designed and will work only when used as documented. Copying parts of it into your own projects will prevent many parts of ILNumerics, including the memory management from functioning. It is also prohibited by the ILNumerics EULA.

Further, the example you are referring to is likely outdated. Please modify your example to use ILNumerics version 6 (or at least 5). You can find many examples on this site: https://ilnumerics.net/examples.html