Reputation: 11
I am just a beginner in programing i wish covert some code from C# to F#,
I have encotered this code:
float[] v1=new float[10]
I need to use this pointer to pass to the function:
ComputeBuffer<float> bufV1 =
new ComputeBuffer<float>(Context, ComputeMemoryFlags.ReadWrite |
ComputeMemoryFlags.UseHostPointer, v1);
If i creat an array in F# like this:
let v1 = [| 1.0..10.0 |]
and call now the funaction like this:
let bufV1 = new ComputeBuffer<float>(Context,
ComputeMemoryFlags.ReadWrite |||
ComputeMemoryFlags.UseHostPointer, v1)
Is it an error?? How do i pass a pointer??
Upvotes: 1
Views: 525
Reputation: 118935
(In .NET, we call these things references to objects; v1
is a reference to an array object. Pointers are something different.)
Note that what F# refers to as float
is what C# calls a double
. You might need
let v1 = [| 1.0f .. 10.0f |]
where the f
suffix makes the values be F# float32
s (e.g. C# float
s).
Upvotes: 5
Reputation: 17119
not an error.
Need to point out that v1
is not a pointer, it is an object in .Net.
Upvotes: 2