nRepeat =20 forn[100200400 a=. tic; for k-1: nRepeat, C=Circulantl(a); end, tl=toc; tic; for k-l: nRepeat, C=Circulant2(a); end, t2=toc; disp(sprintf( %4.0f %05.3f, n, t1/t2)) end n time for circulant 1/circulant 2 10024.694 20035.157 40048468
n time for Circulant1/Circulant2. 100 24.694 200 35.157 400 48.468 nRepeat = 20; for n=[100 200 400] a = 1:n; tic; for k=1:nRepeat, C = Circulant1(a); end, t1 = toc; tic; for k=1:nRepeat, C = Circulant2(a); end, t2 = toc; disp(sprintf(' %4.0f %5.3f',n,t1/t2)) end
a, b2 b3 64 oep T matrices 2 If a and b are n-vectors, then t=toeplitz(a, b)sets up the matrix >L
= 2 3 4 1 3 4 1 2 4 1 2 3 1 2 3 4 a a a a a a a b a a b b a b b b T toeplitz matrices If a and b are n-vectors, then T=toeplitz(a,b) sets up the matrix = − − r j i c i j t j i i j ij
×0000 ×××× ×000 0 ××× L=×××00 U=00××× ×××0 000×× ×××× 0000× Lower triangular ×000 matrices Upper triangular ×××00 matrices T=0×××0 ×× Tridiagonal matrices 000×
= 0 0 0 0 0 0 0 0 0 0 L Lower triangular matrices = 0 0 0 0 0 0 0 0 0 0 U Upper triangular matrices = 0 0 0 0 0 0 0 0 0 0 0 0 T Tridiagonal matrices
Upper bandwidth 2 an=0,j>i+2 ××00000 ×××0000 Lower bandwith 3 ××××000 ×××××00 T a,=0,i>j+3 0 ××××× 0 00×××××× 000×××× 0000××××
= 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 T Lower bandwith 3 Upper bandwidth 2 aij = 0,i j + 3 aij = 0, j i + 2
Diag DIAG(, K) when V is a vector with N components is a square matrix of order n+aBS(K) with the elements of v on the K-th diagonal. K=0 is the main diagonal, K>0 is above the main diagonal andk<0 is below the main diagonal m=5 diag(-m: m)+ diag(ones(2 m, 1),1)+diag(ones(2*m, 1),-1) DIAG(DIAG(X)) is a diagonal matrix
Diag DIAG(V,K) when V is a vector with N components is a square matrix of order N+ABS(K) with the elements of V on the K-th diagonal. K = 0 is the main diagonal, K > 0 is above the main diagonal and K < 0 is below the main diagonal. m = 5; diag(-m:m) + diag(ones(2*m,1),1) + diag(ones(2*m,1),-1) DIAG(DIAG(X)) is a diagonal matrix