help-octave
[Top][All Lists]
Advanced

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

Re: creation of a permutation matrix (WAS: Re: remove for-loop from foll


From: Juan Pablo Carbajal
Subject: Re: creation of a permutation matrix (WAS: Re: remove for-loop from following code)
Date: Sun, 6 Nov 2011 13:30:35 +0100

On Sun, Nov 6, 2011 at 11:05 AM, Carlo de Falco <address@hidden> wrote:
>
> On 6 Nov 2011, at 10:33, c. wrote:
>
>> ------------------------------
>>>> K = 5;
>>>> Y = [1; 3; 2];
>>>> Ytr = eye(K)(Y',:)
>> Ytr =
>>
>>   1   0   0   0   0
>>   0   0   1   0   0
>>   0   1   0   0   0
>>
>> whos Ytr
>> Variables in the current scope:
>>
>>   Attr Name        Size                     Bytes  Class
>>   ==== ====        ====                     =====  =====
>>        Ytr         3x5                        120  double
>>
>> Total is 15 elements using 120 bytes
>> ------------------------------
>>
>> so it stores all the zeros, consuming unnecessary memory.
>> I think this might be a bug and I'll look further into it when I have time,
>
> OK, looking at the definition of idx_vector::is_permutation in idx-vector.cc
> it seems Y will be considered a permutation vector only if it has exactly K 
> elements,
> so only square permutation matrices can be created.
>
> c.
>
>
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://mailman.cae.wisc.edu/listinfo/help-octave
>

Hi,

Indeed, you get the permutation matrix if you use K=max(Y). If you
just want a submatrix out of the full permutation matrix, I think the
only solution to save storage is using a sparse matrix. right?



-- 
M. Sc. Juan Pablo Carbajal
-----
PhD Student
University of Zürich
http://ailab.ifi.uzh.ch/carbajal/


reply via email to

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