01: /* AUTO-GENERATED */
02: package JSci.maths.matrices;
03:
04: import java.awt.Dimension;
05: import java.util.Hashtable;
06: import JSci.maths.algebras.Algebra;
07: import JSci.maths.fields.Ring;
08: import JSci.maths.groups.AbelianGroup;
09:
10: public final class IntegerMatrixAlgebra implements Algebra, Ring {
11: private static final Hashtable algebras = new Hashtable();
12:
13: static IntegerMatrixAlgebra get(int rows, int cols) {
14: Dimension dim = new Dimension(rows, cols);
15: IntegerMatrixAlgebra algebra = (IntegerMatrixAlgebra) algebras
16: .get(dim);
17: if (algebra == null) {
18: algebra = new IntegerMatrixAlgebra(rows, cols);
19: algebras.put(dim, algebra);
20: }
21: return algebra;
22: }
23:
24: private final int rows;
25: private final int cols;
26: private AbstractIntegerMatrix zero;
27: private AbstractIntegerSquareMatrix one;
28:
29: private IntegerMatrixAlgebra(int rows, int cols) {
30: this .rows = rows;
31: this .cols = cols;
32: }
33:
34: /**
35: * Returns the (right) identity.
36: */
37: public Ring.Member one() {
38: if (one == null)
39: one = IntegerDiagonalMatrix.identity(cols);
40: return one;
41: }
42:
43: public boolean isOne(Ring.Member r) {
44: return one().equals(r);
45: }
46:
47: public AbelianGroup.Member zero() {
48: if (zero == null)
49: zero = new IntegerMatrix(rows, cols);
50: return zero;
51: }
52:
53: public boolean isZero(AbelianGroup.Member r) {
54: return zero().equals(r);
55: }
56:
57: public boolean isNegative(AbelianGroup.Member a,
58: AbelianGroup.Member b) {
59: return zero().equals(a.add(b));
60: }
61: }
|