3

When I try to generate 100 x 100 data point using F# and Math.NET using the following code:

let theta0_vals = Generate.LinearSpaced(100, -10.0, 10.0)
let theta1_vals = Generate.LinearSpaced(100, -1.0, 4.0)

let fct a b = 2.0 * a * b

let points = [for i in theta0_vals -> [for j in theta1_vals -> fct (float i) (float j) ]]

then I get the following the following exception:

[System.NullReferenceException: Object reference not set to an instance of an object   at Microsoft.FSharp.Core.Operators.FailurePattern (System.Exception error) [0x00001] in <57a12c4adff9fae1a74503834a2ca157>:0   at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ReraiseIfWatsonable (System.Exception exn) [0x0002d] in <5707a356ddab8ea7a745038356a30757>:0   at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ErrorLogger.ErrorRecovery (Microsoft.FSharp.Compiler.ErrorLogger+ErrorLogger x, System.Exception exn, Microsoft.FSharp.Compiler.Range+range m) [0x00087] in <5707a356ddab8ea7a745038356a30757>:0   at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ReraiseIfWatsonable (System.Exception exn) [0x00040] in <5707a356ddab8ea7a745038356a30757>:0   at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ErrorLogger.ErrorRecovery (Microsoft.FSharp.Compiler.ErrorLogger+ErrorLogger x, System.Exception exn, Microsoft.FSharp.Compiler.Range+range m) [0x00087] in <5707a356ddab8ea7a745038356a30757>:0   at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ReraiseIfWatsonable (System.Exception exn) [0x00040] in <5707a356ddab8ea7a745038356a30757>:0   at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ErrorLogger.ErrorRecovery (Microsoft.FSharp.Compiler.ErrorLogger+ErrorLogger x, System.Exception exn, Microsoft.FSharp.Compiler.Range+range m) [0x00087] in <5707a356ddab8ea7a745038356a30757>:0

I am using the F# interactive in Xamarin Studio on a Mac with 16 GB ram. I have no problems doing the same thing in Matlab.

Is this a limitation in F# and/or Math.NET?

carstenj
  • 693
  • 5
  • 13
  • 2
    What makes you think it's related to memory? It doesn't say anything about that there. If memory really is the issue - in Visual Studio, FSI runs in 32-bit by default and has to be set to 64-bit explicitly. Maybe this is similar in XS. – TeaDrivenDev Oct 31 '16 at 21:15
  • 2
    The 100 in LinearSpaced is the number of points between -10.0 and 10.0. If I lower the number of points then I do not get the exception. That lead me to believe it is memory related. – carstenj Oct 31 '16 at 21:28
  • 3
    I doubt it's a memory problem. I ran your code without any errors from Visual Studio on Windows, can you try running the same code as an executable (no FSI), and see if you get the same error? – mpeac Nov 01 '16 at 01:22
  • Same thing in Azure Notebooks. Even array 50x50 causes exception – Andrii Sep 12 '17 at 20:55

1 Answers1

1

Thanks for your input. It works fine when running in an executable and it also work when running the interactive from the command line. I guess it must be an issue with the integration of the interactive running under Xamarin Studio.

carstenj
  • 693
  • 5
  • 13