KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSci > maths > vectors > MathVector


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

11 public abstract class MathVector extends Object JavaDoc implements Module.Member {
12         /**
13         * The vector's dimension.
14         */

15         protected final int N;
16         /**
17         * Constructs a mathematical vector.
18         * @param n the dimension of the vector.
19         */

20         public MathVector(int n) {
21                 N=n;
22         }
23         /**
24         * Returns the norm (magnitude).
25         */

26         public abstract double norm();
27         /**
28         * Returns the vector's dimension.
29         */

30         public final int dimension() {
31                 return N;
32         }
33         /**
34         * Returns an "invalid component" error message.
35         * @param i index of the component
36         */

37         protected static String JavaDoc getInvalidComponentMsg(int i) {
38                 return "("+i+") is an invalid component for this vector.";
39         }
40 }
41
42
Popular Tags