The most elegant solution that comes to mind is to use *pmap* to generate 
each row of your desired output matrix and then assemble the output to form 
your solution afterwards. 


On Monday, May 25, 2015 at 10:51:55 PM UTC+2, Jérémy Béjanin wrote:
>
> Thanks for the answers.
>
> Would you have a better suggestion on how to do what I want?
>
> As I explained, I am trying to fill two arrays where each array element is 
> a function of the loop index. I realize that at the end of each loop, 
> because the memory is not shared, each array will only have one element 
> filled, and the rest will be zeroes. Adding all of these mostly zeroes 
> arrays together to get the full one does not seem very efficient (or 
> elegant).
>
> Even if I had only one array to fill, the same efficiency issue exists.
>
> I suppose a better way would be for each loop to return only the element, 
> but I would also need to return each elements' array coordinate so that I 
> could build the matrix properly at the end...
>
> On Monday, May 25, 2015 at 2:57:38 PM UTC-4, Mohammed El-Beltagy wrote:
>>
>> Indeed. Also on second thought, I think that reduction on complex types 
>> is not a very good idea. I suspect that with memory allocation at each step 
>> and data copied across processes, it will make for a pretty slow parallel 
>> code. 
>>
>> On Mon, May 25, 2015 at 8:15 PM, Toivo Henningsson <[email protected]> 
>> wrote:
>>
>>> Though you shouldn't really redefine + for types that you haven't 
>>> created yourself. But you could make your own container type where you 
>>> define it, or maybe it's enough to put the two return values in an array. 
>>
>>
>>

Reply via email to