SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.vector.doubles.dense.operation
Class Basis

java.lang.Object
  extended by com.numericalmethod.suanshu.vector.doubles.dense.DenseVector
      extended by com.numericalmethod.suanshu.vector.doubles.dense.operation.Basis
All Implemented Interfaces:
DeepCopyable, AbelianGroup<Vector>, BanachSpace<Vector,Real>, HilbertSpace<Vector,Real>, VectorSpace<Vector,Real>, Vector

public class Basis
extends DenseVector

A basis is a set of linearly independent vectors spanning a vector space. Every element in this space can be uniquely represented by a linear combination of elements in the basis.

This class implements the standard basis in the Euclidean Rn space.

See Also:
Wikipedia: Basis (linear algebra)

Field Summary
 
Fields inherited from class com.numericalmethod.suanshu.vector.doubles.dense.DenseVector
length
 
Constructor Summary
Basis(int dim, int i)
          Construct a vector which corresponds to the i-th dimension in Rn.
 
Method Summary
 double angle(Vector that)
          Measure the angle between this and that.
static VectorList basis(int dim)
          Get the full set of standard basis vectors.
static VectorList basis(int dim, int ncols)
          Get a subset of standard basis vectors.
 double norm()
          Compute the length or magnitude or Euclidean norm of a vector, namely, ||v||.
 Vector opposite()
          Get the opposite of this vector.
 Vector scaled(Real scalar)
          scalar * that If scalar is 1, it simply returns itself.
 
Methods inherited from class com.numericalmethod.suanshu.vector.doubles.dense.DenseVector
add, add, add, as, deepCopy, divide, divide, equals, get, hashCode, innerProduct, minus, minus, minus, multiply, multiply, norm, pow, scaled, set, set, size, toArray, toString, ZERO
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Basis

public Basis(int dim,
             int i)
Construct a vector which corresponds to the i-th dimension in Rn. That is,
 |  0  |
 | ... |
 |  1  | <-- the i-th entry
 | ... |
 |  0  |
 

Parameters:
dim - the dimension
i - the i-th dimension in Rn
Method Detail

basis

public static VectorList basis(int dim)
Get the full set of standard basis vectors.

Parameters:
dim - the dimension
Returns:
the basis vectors

basis

public static VectorList basis(int dim,
                               int ncols)
Get a subset of standard basis vectors.

Parameters:
dim - the dimension
ncols - number of basis vectors requested; it must be smaller than dim
Returns:
the basis vectors
Throws:
java.lang.IllegalArgumentException - if there are more columns requested than the dimension

scaled

public Vector scaled(Real scalar)
Description copied from interface: Vector
scalar * that

If scalar is 1, it simply returns itself. So, here is a way to get a unit version of the vector:

vector.scaled(1. / vector.norm())

Specified by:
scaled in interface VectorSpace<Vector,Real>
Specified by:
scaled in interface Vector
Parameters:
scalar - a Real number scalar
Returns:
a vector which is scaled by scalar
See Also:
Wikipedia: Scalar multiplication

opposite

public Vector opposite()
Description copied from interface: Vector
Get the opposite of this vector.

Specified by:
opposite in interface AbelianGroup<Vector>
Specified by:
opposite in interface Vector
Returns:
-v
See Also:
Wikipedia: Additive inverse

angle

public double angle(Vector that)
Description copied from interface: Vector
Measure the angle between this and that.

That is,

this ∙ that = ||this|| * ||that|| cos(angle)

Specified by:
angle in interface HilbertSpace<Vector,Real>
Specified by:
angle in interface Vector
Parameters:
that - a vector
Returns:
the angle between this and that

norm

public double norm()
Description copied from interface: Vector
Compute the length or magnitude or Euclidean norm of a vector, namely, ||v||.

Specified by:
norm in interface BanachSpace<Vector,Real>
Specified by:
norm in interface Vector
Returns:
the Euclidean norm
See Also:
Wikipedia: Norm (mathematics)

SuanShu, a Java numerical and statistical library

Copyright © 2011 Numerical Method Inc. Ltd. All Rights Reserved.