当我尝试使用 F# 和 Math.NET 使用以下代码生成 100 x 100 数据点时:
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) ]]
然后我得到以下异常:
[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
我在配备 16 GB 内存的 Mac 上的 Xamarin Studio 中使用 F# 交互式。我在 Matlab 中做同样的事情没有问题。
这是 F# 和/或 Math.NET 的限制吗?
最佳答案
感谢您的输入。它在可执行文件中运行时工作正常,并且在从命令行运行交互式时也能正常工作。我想应该是 Xamarin Studio 下运行的交互集成的问题。
关于.net - 生成 100 x 100 数据点时来自 Math.NET 的内存异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40350362/