csharpfftfsharpintegrationinterpolationlinear-algebramathdifferentiationmatrixnumericsrandomregressionstatisticsmathnet
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
847 B
30 lines
847 B
// (c) Microsoft Corporation 2005-2009.
|
|
|
|
#nowarn "9"
|
|
|
|
namespace Microsoft.FSharp.Compatibility
|
|
|
|
module Array2D =
|
|
|
|
open System.Runtime.InteropServices
|
|
|
|
let inline pinObjUnscoped (obj: obj) =
|
|
GCHandle.Alloc(obj,GCHandleType.Pinned)
|
|
|
|
let inline pinObj (obj: obj) f =
|
|
let gch = pinObjUnscoped obj
|
|
try f gch
|
|
finally
|
|
gch.Free()
|
|
|
|
[<NoDynamicInvocation>]
|
|
let inline pin (arr: 'T [,]) (f : nativeptr<'T> -> 'U) =
|
|
pinObj (box arr) (fun _ -> f (NativeInterop.NativePtr.of_array2 arr 0 0))
|
|
|
|
[<NoDynamicInvocation>]
|
|
let inline pinUnscoped (arr: 'T [,]) : nativeptr<'T> * _ =
|
|
let gch = pinObjUnscoped (box arr) in
|
|
NativeInterop.NativePtr.of_array2 arr 0 0, gch
|
|
|
|
[<NoDynamicInvocation>]
|
|
let inline pin_unscoped arr = pinUnscoped arr
|
|
|