我想在F#中使用Brahma库并调用一个带有表达式参数的方法,但我不知道该如何做。
这是我想翻译的C#代码:
// Create the computation provider
var computationProvider = new ComputationProvider();
// Create a data-parallel array and fill it with data
var data = new DataParallelArray<float>(computationProvider,
new[] { 0f, 1f, 2f, 3f, 4f, 5f, 6f });
// Compile the query
CompiledQuery query = computationProvider.Compile<DataParallelArray<float>>
(
d => from value in d
select value * 2f
);
// Run the query on this data
IQueryable result = computationProvider.Run(query, data);
// Print out the results
foreach (float value in result)
Console.WriteLine(result[i]);
// Get rid of all the stuff we created
computationProvider.Dispose();
data.Dispose();
result.Dispose();