KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSci > maths > matrices > Matrix


1 package JSci.maths.matrices;
2
3 import JSci.maths.algebras.Algebra;
4
5 /**
6 * The Matrix superclass provides an abstract encapsulation for matrices.
7 * @jsci.planetmath Matrix
8 * @version 2.2
9 * @author Mark Hale
10 */

11 public abstract class Matrix extends Object JavaDoc 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         * Constructs a matrix.
22         */

23         public Matrix(int rows, int cols) {
24                 numRows = rows;
25                 numCols = cols;
26         }
27         /**
28         * Returns the number of rows.
29         */

30         public final int rows() {
31                 return numRows;
32         }
33         /**
34         * Returns the number of columns.
35         */

36         public final int columns() {
37                 return numCols;
38         }
39         /**
40         * Returns the transpose of this matrix.
41         * @jsci.planetmath Transpose
42         */

43         public abstract Matrix transpose();
44         /**
45         * Returns an "invalid element" error message.
46         * @param i row index of the element
47         * @param j column index of the element
48         */

49         protected static String JavaDoc getInvalidElementMsg(int i, int j) {
50                 return "("+i+','+j+") is an invalid element for this matrix.";
51         }
52 }
53
Popular Tags