User`s guide

gop
11-125
gop
Global operation across all workers
Syntax
res = gop(FUN,x)
res = gop(FUN,x,targetlab)
Arguments
FUN Function to operate across workers.
x Argument to function F, should be the same variable on all workers, but
can have different values.
res Variable to hold reduction result.
targetlab Lab to which reduction results are returned. This value is returned by
that worker’s labindex.
Description
res = gop(FUN,x) is the reduction via the function FUN of the quantities x from each
worker. The result is duplicated on all workers.
FUN can be a handle to any function, including user-written functions and user-defined
anonymous functions. It should accept two arguments of the same type, and return one
result of that same type, so it can be used iteratively in the form:
FUN(FUN(x1,x2),FUN(x3,x4))
The function FUN should be associative, that is,
FUN(FUN(x1,x2),x3) = FUN(x1,FUN(x2,x3))
res = gop(FUN,x,targetlab) performs the reduction, and places the result into res
only on the worker indicated by targetlab. res is set to [ ] on all other workers.