annotate util/ksvd utils/spdiag.m @ 183:0d7a81655ef2 danieleb

removed cumulative coherence calculation
author Daniele Barchiesi <daniele.barchiesi@eecs.qmul.ac.uk>
date Fri, 27 Jan 2012 13:15:11 +0000
parents c3eca463202d
children
rev   line source
idamnjanovic@70 1 function Y = spdiag(V,K)
idamnjanovic@70 2 %SPDIAG Sparse diagonal matrices.
idamnjanovic@70 3 % SPDIAG(V,K) when V is a vector with N components is a sparse square
idamnjanovic@70 4 % matrix of order N+ABS(K) with the elements of V on the K-th diagonal.
idamnjanovic@70 5 % K = 0 is the main diagonal, K > 0 is above the main diagonal and K < 0
idamnjanovic@70 6 % is below the main diagonal.
idamnjanovic@70 7 %
idamnjanovic@70 8 % SPDIAG(V) is the same as SPDIAG(V,0) and puts V on the main diagonal.
idamnjanovic@70 9 %
idamnjanovic@70 10 % See also DIAG, SPDIAGS.
idamnjanovic@70 11
idamnjanovic@70 12
idamnjanovic@70 13 % Ron Rubinstein
idamnjanovic@70 14 % Computer Science Department
idamnjanovic@70 15 % Technion, Haifa 32000 Israel
idamnjanovic@70 16 % ronrubin@cs
idamnjanovic@70 17 %
idamnjanovic@70 18 % June 2008
idamnjanovic@70 19
idamnjanovic@70 20
idamnjanovic@70 21 if (nargin<2)
idamnjanovic@70 22 K = 0;
idamnjanovic@70 23 end
idamnjanovic@70 24
idamnjanovic@70 25 n = length(V) + abs(K);
idamnjanovic@70 26
idamnjanovic@70 27 if (K>0)
idamnjanovic@70 28 i = 1:length(V);
idamnjanovic@70 29 j = K+1:n;
idamnjanovic@70 30 elseif (K<0)
idamnjanovic@70 31 i = -K+1:n;
idamnjanovic@70 32 j = 1:length(V);
idamnjanovic@70 33 else
idamnjanovic@70 34 i = 1:n;
idamnjanovic@70 35 j = 1:n;
idamnjanovic@70 36 end
idamnjanovic@70 37
idamnjanovic@70 38 Y = sparse(i,j,V(:),n,n);