01: package JSci.maths.vectors;
02:
03: import JSci.maths.algebras.Module;
04:
05: /**
06: * The MathVector superclass provides an abstract encapsulation for vectors.
07: * @jsci.planetmath Vector
08: * @version 2.2
09: * @author Mark Hale
10: */
11: public abstract class MathVector extends Object implements
12: Module.Member {
13: /**
14: * The vector's dimension.
15: */
16: protected final int N;
17:
18: /**
19: * Constructs a mathematical vector.
20: * @param n the dimension of the vector.
21: */
22: public MathVector(int n) {
23: N = n;
24: }
25:
26: /**
27: * Returns the norm (magnitude).
28: */
29: public abstract double norm();
30:
31: /**
32: * Returns the vector's dimension.
33: */
34: public final int dimension() {
35: return N;
36: }
37:
38: /**
39: * Returns an "invalid component" error message.
40: * @param i index of the component
41: */
42: protected static String getInvalidComponentMsg(int i) {
43: return "(" + i + ") is an invalid component for this vector.";
44: }
45: }
|