01: package JSci.maths.matrices;
02:
03: import JSci.maths.algebras.Algebra;
04:
05: /**
06: * The Matrix superclass provides an abstract encapsulation for matrices.
07: * @jsci.planetmath Matrix
08: * @version 2.2
09: * @author Mark Hale
10: */
11: public abstract class Matrix extends Object implements Algebra.Member {
12: /**
13: * The number of rows.
14: */
15: protected final int numRows;
16: /**
17: * The number of columns.
18: */
19: protected final int numCols;
20:
21: /**
22: * Constructs a matrix.
23: */
24: public Matrix(int rows, int cols) {
25: numRows = rows;
26: numCols = cols;
27: }
28:
29: /**
30: * Returns the number of rows.
31: */
32: public final int rows() {
33: return numRows;
34: }
35:
36: /**
37: * Returns the number of columns.
38: */
39: public final int columns() {
40: return numCols;
41: }
42:
43: /**
44: * Returns the transpose of this matrix.
45: * @jsci.planetmath Transpose
46: */
47: public abstract Matrix transpose();
48:
49: /**
50: * Returns an "invalid element" error message.
51: * @param i row index of the element
52: * @param j column index of the element
53: */
54: protected static String getInvalidElementMsg(int i, int j) {
55: return "(" + i + ',' + j
56: + ") is an invalid element for this matrix.";
57: }
58: }
|