很多数组边界检查的减慢速度,这是特别真实的二维数组。有没有一种方法来在F#中写的不安全code块?
A lot of array boundary checking slows down the speed, this is especially true to 2D arrays. Is there a way to write unsafe code blocks in F#?
我不是一个的 F#程序员,但据我可以看到它似乎不具备的不安全关键字。
I'm not a F# programmer but as far as I can see it doesn't seem to have the unsafe keyword.
你可能得到的性能提升了二维数组转化为一个一维数组。
You could possibly get a performance boost by transforming the 2D array to an one-dimensional array.
建议5:直到我们得到这个权利,我 将表明.NET用户做什么 许多C ++程序员的数值做: 写一个类来实现你的 n维阵列。这将是 重新presented作为1维阵列 和有关的访问会 通过转换n个索引为1 适当的乘法。我们 几乎可以肯定不会消除 边界检查到一维数组, 但至少我们会只做一查!
Advice 5: Until we get this right, I would suggest that .NET users do what many C++ numerical programmers do: write a class to implement your n-dimensional array. This would be represented as a 1-dimensional array, and the relevant accessors would convert n indices into 1 via appropriate multiplications. We almost certainly wouldn’t eliminate the bounds check into the 1-d array, but at least we’d only do one check!
Array边界检查消除在CLR