Mercurial > hg > smallbox
annotate DL/RLS-DLA/private/diag_ids.m @ 63:e08af264ef93
(none)
author | idamnjanovic |
---|---|
date | Tue, 15 Mar 2011 12:23:35 +0000 |
parents | ad36f80e2ccf |
children |
rev | line source |
---|---|
idamnjanovic@60 | 1 function id = diag_ids(x,k) |
idamnjanovic@60 | 2 %DIAG_IDS Indices of matrix diagonal elements. |
idamnjanovic@60 | 3 % ID = DIAG_IDS(X) returns the indices of the main diagonal of X. |
idamnjanovic@60 | 4 % |
idamnjanovic@60 | 5 % ID = DIAG_IDS(X,K) returns the indices of the K-th diagonal. K=0 |
idamnjanovic@60 | 6 % represents the main diagonal, positive values are above the main |
idamnjanovic@60 | 7 % diagonal and negative values are below the main diagonal. |
idamnjanovic@60 | 8 |
idamnjanovic@60 | 9 |
idamnjanovic@60 | 10 % Ron Rubinstein |
idamnjanovic@60 | 11 % Computer Science Department |
idamnjanovic@60 | 12 % Technion, Haifa 32000 Israel |
idamnjanovic@60 | 13 % ronrubin@cs |
idamnjanovic@60 | 14 % |
idamnjanovic@60 | 15 % September 2006 |
idamnjanovic@60 | 16 |
idamnjanovic@60 | 17 |
idamnjanovic@60 | 18 if (nargin==1), k=0; end |
idamnjanovic@60 | 19 |
idamnjanovic@60 | 20 [m,n] = size(x); |
idamnjanovic@60 | 21 l = max(m,n); |
idamnjanovic@60 | 22 |
idamnjanovic@60 | 23 if (k<=0) |
idamnjanovic@60 | 24 id = (0:l-1)*m + (1:l) - k; |
idamnjanovic@60 | 25 else |
idamnjanovic@60 | 26 id = (0:l-1)*m + (1:l) + k*m; |
idamnjanovic@60 | 27 end |
idamnjanovic@60 | 28 |
idamnjanovic@60 | 29 if (l-k>m), id = id(1:end-(l-k-m)); end |
idamnjanovic@60 | 30 if (l+k>n), id = id(1:end-(l+k-n)); end |