You can use ParallelEnumerable.Skip and .Take to skip a number of elements, then take a certain number, which essentially allows you to query a range.
This will be A.AsParallel().Skip(low).Take(high-low+1).Select(...
سؤال
I'd like to rewrite this Parallel.For loop using a PLINQ method AsParallel(). As far as I have seen, AsParallel() requires passing an entire sequence to it, eg create Array A, then call A.AsParallel().ForAll or A.AsParallel().Select . Is there a way to make AsParallel() work on a range - in this case, from low to high?
for k = 2 to m+n do
let low = max 1 (k-m)
let high = min (k-1) n
Parallel.For(low, high + 1, (fun j ->
المحلول 2
You can use ParallelEnumerable.Skip and .Take to skip a number of elements, then take a certain number, which essentially allows you to query a range.
This will be A.AsParallel().Skip(low).Take(high-low+1).Select(...
نصائح أخرى
One way to do this would be to use ParallelEnumerable.Range()
:
ParallelEnumerable.Range(low, high-low+1).Select(fun i -> let a = A.[i] in …)