Mercurial > matrix-functions
comparison toolbox/dramadah.m @ 0:8f23314345f4 draft
Create local repository for matrix toolboxes. Step #0 done.
author | Antonio Pino Robles <data.script93@gmail.com> |
---|---|
date | Wed, 06 May 2015 14:56:53 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:8f23314345f4 |
---|---|
1 function A = dramadah(n, k) | |
2 %DRAMADAH A (0,1) matrix whose inverse has large integer entries. | |
3 % An anti-Hadamard matrix A is a matrix with elements 0 or 1 for | |
4 % which MU(A) := NORM(INV(A),'FRO') is maximal. | |
5 % A = DRAMADAH(N, K) is an N-by-N (0,1) matrix for which MU(A) is | |
6 % relatively large, although not necessarily maximal. | |
7 % Available types (the default is K = 1): | |
8 % K = 1: A is Toeplitz, with ABS(DET(A)) = 1, and MU(A) > c(1.75)^N, | |
9 % where c is a constant. | |
10 % K = 2: A is upper triangular and Toeplitz. | |
11 % The inverses of both types have integer entries. | |
12 % | |
13 % Another interesting (0,1) matrix: | |
14 % K = 3: A has maximal determinant among (0,1) lower Hessenberg | |
15 % matrices: det(A) = the n'th Fibonacci number. A is Toeplitz. | |
16 % The eigenvalues have an interesting distribution in the complex | |
17 % plane. | |
18 | |
19 % References: | |
20 % R.L. Graham and N.J.A. Sloane, Anti-Hadamard matrices, | |
21 % Linear Algebra and Appl., 62 (1984), pp. 113-137. | |
22 % L. Ching, The maximum determinant of an nxn lower Hessenberg | |
23 % (0,1) matrix, Linear Algebra and Appl., 183 (1993), pp. 147-153. | |
24 | |
25 if nargin < 2, k = 1; end | |
26 | |
27 if k == 1 % Toeplitz | |
28 | |
29 c = ones(n,1); | |
30 for i=2:4:n | |
31 m = min(1,n-i); | |
32 c(i:i+m) = zeros(m+1,1); | |
33 end | |
34 r = zeros(n,1); | |
35 r(1:4) = [1 1 0 1]; | |
36 if n < 4, r = r(1:n); end | |
37 A = toeplitz(c,r); | |
38 | |
39 elseif k == 2 % Upper triangular and Toeplitz | |
40 | |
41 c = zeros(n,1); | |
42 c(1) = 1; | |
43 r = ones(n,1); | |
44 for i=3:2:n | |
45 r(i) = 0; | |
46 end | |
47 A = toeplitz(c,r); | |
48 | |
49 elseif k == 3 % Lower Hessenberg. | |
50 | |
51 c = ones(n,1); | |
52 for i=2:2:n, c(i)=0; end; | |
53 A = toeplitz(c, [1 1 zeros(1,n-2)]); | |
54 | |
55 end |