AbstractVector an element of FN.
Inherits from: Object : Collection : SequenceableCollection : ArrayedCollection : AbstractVector
Represents an element of FN, where F is either the real numbers R or the complex numbers C. Usual operations are implemented. Examples are given with RealVector.
Creation / Class Methods
*new (args)
Create new vector from a n-tuple of real numbers. Dimension of the vector is determined by the amount of numbers.
RealVector[1.2,0.3,5.6,3.2]
*gramSchmidt (vectors)
Applies the gramSchmidt process to the vectors and returns an array of orthogonal vectors that span the same subspace as the original vectors. Note: rounding erros will usually not give you completely orthogonal vectors.
a = RealVector[1,2];
b = RealVector[3,4];
c = RealVector.gramSchmidt([a,b])
c[0]<|>c[1]
Accessing Instance and Class Variables
x,y,z
components for vectors up to 3 dimensions.
RealVector[1,2,3].x
<|> (vector)
inner product.
RealVector[1,2,3]<|>RealVector[2,5,7]
ComplexVector[Complex(1,0),Complex(1,2)]<|>ComplexVector[Complex(1,3),Complex(0,2)]
// the canonical base in R^N is orthogonal
3.collect{ |i| RealVector.canonB(i, 3)<|>RealVector.canonB((i+1).mod(3), 3) };
dist (vector)
distance.
RealVector[1,2,3].dist(RealVector[2,5,7])
ComplexVector[Complex(1,0),Complex(1,2)].dist(ComplexVector[Complex(1,3),Complex(0,2)])
norm
euclidian norm - sqrt( vector <|> vector ).
RealVector[0,2,0].norm
ComplexVector[Complex(1,0),Complex(1,2)].norm
normalize
RealVector[7,2,3].normalize.norm
ComplexVector[Complex(1,0),Complex(1,2)].normalize.norm
isOrthogonal (vector)
RealVector[0,0,1,0].isOrthogonal(RealVector[1,0,0,0])
ComplexVector[Complex(1,0),Complex(0,2)].isOrthogonal(ComplexVector[Complex(0,3),Complex(0,2)])
usual vector space operations
RealVector[1,2,3] + RealVector[4,5,6]
RealVector[1,2,3]*2
ComplexVector[Complex(1,0),Complex(0,2)]+ComplexVector[Complex(0,3),Complex(0,2)]
ComplexVector[Complex(1,0),Complex(0,2)]*Complex(1,2)
transpose
returns the transposed vector as a one row matrix.
RealVector[0,0,1,0].transpose
proj (vector)
projects vector into the current vector.
RealVector[0,0,1].proj(RealVector[3.2,5.6,3.6])