[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: |
Carlo de Falco |
Subject: |
Re: creation of a permutation matrix (WAS: Re: remove for-loop from following code) |
Date: |
Sun, 6 Nov 2011 11:05:50 +0100 |
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.