pcall

Syntax

pcall(func, args...)

Arguments

func is an aggregate function. The output of the function must be a vector or a table with the same length as all vectors or table columns in args.

args are the arguments of func. Each argument must be a table, a vector or a tuple of vectors. All the vectors or table columns in args must have the same length.

Details

Conduct parallel computing of a vector function. pcall divides each argument into multiple parts and conducts the calculation in parallel. If the length of the vectors or table columns of the input variables is less than 100,000, pcall will not conduct the calculation in parallel.

Examples

x = rand(1.0, 10000000);
timer(10) sin(x);
Time elapsed: 739.561 ms

timer(10) pcall(sin, x);
Time elapsed: 404.56 ms