|
G:\E-study\2005__Proj\src\MatrixList.java
|
1
2 import java.util.Vector;
3
4 /**
5 * This method is used in the generation of Ramanujan-LPS graph vertices. Since the vertices of Ramanujan-LPS graph are
6 * some precalculated matrices, they have to be calculated.
7 * Created by IntelliJ IDEA.
8 * User: Max B.
9 * Date: Nov 4, 2004
10 * Time: 9:33:04 PM
11 */
12 public class MatrixList {
13
14 /**
15 * A list used to save the Matrices created.
16 */
17 private Vector list;
18
19 /**
20 * C-tor of the class.
21 * The duty of the c-tor is to initialie whatever values need initialization and vreate a
22 * list of matrixes which are not alike in the sence of multiplication
23 *
24 * @param q
25 */
26 public MatrixList(int q) {
27 list = new Vector();
28 this.generateMatrixList(q);
29 System.out.println("Creation of the Matrix list finished");
30
31 }
32
33
34 /**
35 * Public accessor
36 * @param i
37 * @return
38 */
39 public MyMatrix MatrixAt(int i){
40 return (MyMatrix)( list.elementAt(i));
41 }
42
43
44 /**
45 * Public accessor
46 * @return
47 */
48 public Vector getList() {
49 return list;
50 }
51
52 /**
53 * Prints the matrixes on the list.
54 */
55 public void printMatrixList() {
56 for (int i = 0; i < list.size(); i++) {
57 ((MyMatrix) (list.elementAt(i))).print();
58 }
59 }
60
61 /**
62 * This method generates the matrixes to be entered to the list themselves and enters them to the list.
63 * @param q
64 */
65 public void generateMatrixList(int q) {
66 MyMatrix m;
67 int cnt1 = 0;
68 int cnt2 = 0;
69
70 for (int i = 0; i < q; i++) {
71 for (int j = 0; j < q; j++) {
72 for (int k = 0; k < q; k++) {
73 m = new MyMatrix(1, k, j, i);
74 cnt1++;
75 if (m.det() != 0)
76 list.addElement(m);
77 else
78 cnt2++;
79 }
80 }
81 }
82
83 for (int l = 0; l < q; l++) {
84 for (int h = 0; h < q; h++) {
85 m = new MyMatrix(0, 1, h, l);
86 cnt1++;
87 if (m.det() != 0)
88 list.addElement(m);
89 else
90 cnt2++;
91 }
92 }
93 System.out.println("Matrixes tried (q^3+ q^2) = " + cnt1);
94 System.out.println("Matrixes skipped (det=0) = " + cnt2);
95 }
96
97 /**
98 * This method checks wheather there are "proportional" matrices in the list generated, if there are, then the list is wrong.
99 * @return returns number of proportional matrices found, 0 for none.
100 */
101 public int checkIntegrity() {
102 MyMatrix m;
103 int cnt = 0;
104 for (int i = 0; i < list.size(); i++) {
105 m = (MyMatrix) list.elementAt(i);
106 for (int j = 0; j < list.size(); j++) {
107 if (j != i)
108 if (m.similar((MyMatrix) list.elementAt(j))) {
109 System.out.println("Similar matrices found : ");
110 m.print();
111 ((MyMatrix) list.elementAt(j)).print();
112 System.out.println("----------------------- ");
113 cnt++;
114
115 }
116 }
117 }
118 return cnt;
119 }
120
121
122 /**
123 * @return returns the number of generated matrixes
124 */
125 public int length() {
126 return list.size();
127 }
128
129
130 }
131