help-octave
[Top][All Lists]
Advanced

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

Re: Pararrayfun


From: Clinton Winant
Subject: Re: Pararrayfun
Date: Mon, 13 Mar 2017 09:42:08 -0700

Many thanks again. I completely agree to stick with the specified behavior. I have modified my script as follows:

clear all;
nproc=4;
function N = single_thread (arg)
  Array2d=arg*[1,i;-i,1];
  N=Array2d(:);
endfunction
b = pararrayfun (nproc, @single_thread, [1:5], "UniformOutput", false);

which works (you already knew that), size(b) returns 1 5, even though  for instance b[1,1] has four elements.  If b was an array, it would be 4 by 5, so it must be  a cell. It must be clear to you by now I dont understand cells.

I will learn about cells and use what you have given me for my real problem.

I notice that on http://wiki.octave.org/Parallel_package  it doesnt say much about the three options (Chunks Per Proc, UniformOutput and Vectorized), although the examples give some info?  Would you like me to expand the documentation (the answers would have to come from you), or is there any other way I could contribute?  This seems such an important (and unique) feature of octave.








On Sun, Mar 12, 2017 at 10:54 PM, Olaf Till <address@hidden> wrote:
On Sun, Mar 12, 2017 at 03:26:43PM -0700, Clinton Winant wrote:
> Many thanks for your helpful reply.  I understand that with "Vectorized",
> the output can be a 2d matrix, but I am not quite there yet.  I modified
> your script as:
>
> clear all;
> nproc=4;
>
> function N = single_thread (arg)
>   Array2d=arg*[1,i;-i,1];
>   N=Array2d(:);
> endfunction

This function doesn't handle vectors as accepted, so you can't specify
"Vectorized". But if the function returns more elements than it gets
as argument, without "UniformOutput" set to false, we rely on
unspecified behavior, and it works only in special cases.

I think we should stick with the specified behavior. Your function
should return as many elements as given in "arg". If it can handle
only a scalar "arg", don't specify "Vectorized". If it returns a
matrix for a scalar "arg", as it does currently, don't specify
"Vectorized", but specify ..., "UniformOutput", false, ... and
concatenate the result manually e.g. with

b = pararrayfun (nproc, @single_thread, [1:5], "UniformOutput", false);

result = cat (1, b{:});

Olaf

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


reply via email to

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