[Top][All Lists]

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

Re: Is transpose costless?

From: John W. Eaton
Subject: Re: Is transpose costless?
Date: Mon, 15 Jul 2019 13:07:38 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2

On 7/15/19 11:47 AM, Rik wrote:

I had a question about optimization in the parser.  If I write

x = x.';

is that effectively a costless operation that simply swaps the first two
values of the dimension vector?  Or does Octave first create a temporary
intermediate (which is costless because of COW), but then the transpose
operator forces a deep copy to the intermediate, and then the final
assignment takes place (also potentially another deep copy).

Transpose for Array<T> objects, which includes numeric arrays, cell arrays, and values of the fields of struct arrays (because they are stored as cell arrays) is handled in liboctave/array/Array.cc. Transpose only works for 2-dimensional arrays and there is a special case for empty arrays and vectors that just swaps the dimensions and shares the data array. Otherwise, if the number of rows and columns are both greater than 1, we have to copy data.


reply via email to

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