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: Mon, 13 Mar 2017 06:54:17 +0100
User-agent: Mutt/1.5.23 (2014-03-12)

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

Attachment: signature.asc
Description: Digital signature


reply via email to

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