help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Pararrayfun


From: Olaf Till
Subject: Re: Pararrayfun
Date: Sun, 12 Mar 2017 18:21:21 +0100
User-agent: Mutt/1.5.23 (2014-03-12)

On Sat, Mar 11, 2017 at 04:06:26PM -0800, Clinton Winant wrote:
> I want to use the parallel package to furnish a large 4 dimensional array.
> The following:
> 
> clear;
> function a=single_thread(ky);
>   a(:,:,1)=ky*[1,2;4,5];
>   a(:,:,2)=[1,2;4,5];
>   a(:,:,3)=-ky*[1,2;4,5];
> endfunction
> 
> b=pararrayfun(4,@single_thread,[1:4],"ChunksPerProc", 1)
> 
> works

by some chance. As arrayfun, pararrayfun with "vectorized" not set to
true by default expects the user function to return a single
element. With "vectorized" set to true, pararrayfun expects the user
function an array of the same dimensions as the user functions input
argument(s).

You can set "UniformOutput" to false and concatenate the the results
in the returned cell array manually.

If you want to go in for some hassle to optimize your processing, read on.

Currently pararrayfun is written in a way making the following work:

octave:1> function a = fmultdim (arg)
> a = cat (4, cat (3, [1; 2], [3; 4]), cat (3, arg * [1; 2], arg * [3; 4]), cat 
> (3, [1; 2], [3; 4]));
> endfunction

octave:2> b = pararrayfun (4, @fmultdim, [1:5])
parcellfun: 5/5 jobs done
b =

ans(:,:,1,1) =

   1   1   1   1   1
   2   2   2   2   2

...

But if you give "ChunksPerProc" with "vectorized" false, cellfun is
called internally, and doesn't accept this input. If you set
"vectorized" to true, it should work if you change the user function
to accept row vectors and return the corresponding number of slices
along dimension 2.

Olaf

-- 
public key id EAFE0591, e.g. on x-hkp://pool.sks-keyservers.net

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]