org.jscience.mathematics.algebraic.matrices
Class DoubleVector

java.lang.Object
  extended by org.jscience.mathematics.algebraic.AbstractHypermatrix
      extended by org.jscience.mathematics.algebraic.AbstractMatrix
          extended by org.jscience.mathematics.algebraic.AbstractVector
              extended by org.jscience.mathematics.algebraic.matrices.AbstractDoubleVector
                  extended by org.jscience.mathematics.algebraic.matrices.DoubleVector
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Algebra.Member, BanachSpace.Member, Ring.Member, AbelianGroup.Member, Hypermatrix, Matrix, Module.Member, VectorSpace.Member, Vector, Member

public class DoubleVector
extends AbstractDoubleVector
implements java.lang.Cloneable, java.io.Serializable

An array-based implementation of an double vector.

See Also:
Serialized Form

Field Summary
protected  double[] vector
          Array containing the components of the vector.
 
Constructor Summary
DoubleVector(AbstractDoubleVector vec)
          Constructs a vector by copying a vector.
DoubleVector(double[] array)
          Constructs a vector by wrapping an array.
DoubleVector(int dim)
          Constructs an empty vector.
 
Method Summary
 AbelianGroup.Member add(AbelianGroup.Member v)
          Returns the addition of this vector and another.
 AbstractDoubleVector add(AbstractDoubleVector v)
          Returns the addition of this vector and another.
 DoubleVector add(DoubleVector v)
           
 java.lang.Object clone()
          Clone vector into a new vector.
 boolean equals(java.lang.Object a, double tol)
          Compares two double vectors for equality.
 double getPrimitiveElement(int n)
          Returns an element of this vector.
 double infNorm()
          Returns the linfinity-norm.
 AbstractDoubleVector mapElements(PrimitiveMapping f)
          Applies a function on all the vector components.
 double mass()
          Returns the mass.
 AbelianGroup.Member negate()
          Returns the negative of this vector.
 double norm()
          Returns the l2-norm (magnitude).
 double norm(int n)
          Returns the ln-norm.
 void normalize()
          Makes the norm of this vector equal to 1.
 AbstractDoubleVector scalarDivide(double x)
          Returns the division of this vector by a scalar.
 VectorSpace.Member scalarDivide(Field.Member x)
          Returns the division of this vector by a scalar.
 AbstractDoubleVector scalarMultiply(double x)
          Returns the multiplication of this vector by a scalar.
 Module.Member scalarMultiply(Ring.Member x)
          Returns the multiplication of this vector by a scalar.
 double scalarProduct(AbstractDoubleVector v)
          Returns the scalar product of this vector and another.
 double scalarProduct(DoubleVector v)
           
 void setAllElements(double r)
          Sets the value of all elements of the vector.
 void setElement(int n, double x)
          Sets the value of a element of this vector.
 AbelianGroup.Member subtract(AbelianGroup.Member v)
          Returns the subtraction of this vector by another.
 AbstractDoubleVector subtract(AbstractDoubleVector v)
          Returns the subtraction of this vector by another.
 DoubleVector subtract(DoubleVector v)
           
 double sumSquares()
          Returns the sum of the squares of the components.
 AbstractComplexVector toComplexVector()
          Converts this vector to a complex vector.
 AbstractIntegerVector toIntegerVector()
          Converts this vector to an integer vector.
 double[] toPrimitiveArray()
          Projects the vector to an array.
 java.lang.String toString()
          Returns a comma delimited string representing the value of this vector.
 
Methods inherited from class org.jscience.mathematics.algebraic.matrices.AbstractDoubleVector
abs, equals, getColumn, getElement, getRow, getSubVector, hashCode, max, mean, min, multiply, read, reverse, setColumn, setElement, setRow, setSubVector, standardDeviation, tensorProduct, toMatrix, transpose, variance
 
Methods inherited from class org.jscience.mathematics.algebraic.AbstractVector
getDimension, getElement, getInvalidElementMsg, toArray, toArray
 
Methods inherited from class org.jscience.mathematics.algebraic.AbstractMatrix
getElement, getInvalidElementMsg, numColumns, numRows, print, print, print, print, toArray
 
Methods inherited from class org.jscience.mathematics.algebraic.AbstractHypermatrix
getDimensions, numDimensions, numElements, numElements, toArray
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jscience.mathematics.algebraic.Matrix
numColumns, numRows, toArray
 
Methods inherited from interface org.jscience.mathematics.algebraic.Hypermatrix
getDimensions, getElement, numDimensions, numElements, numElements, toArray
 

Field Detail

vector

protected double[] vector
Array containing the components of the vector.

Constructor Detail

DoubleVector

public DoubleVector(int dim)
Constructs an empty vector.

Parameters:
dim - the dimension of the vector.

DoubleVector

public DoubleVector(double[] array)
Constructs a vector by wrapping an array.

Parameters:
array - an assigned value.

DoubleVector

public DoubleVector(AbstractDoubleVector vec)
Constructs a vector by copying a vector.

Parameters:
vec - an assigned value
Method Detail

equals

public boolean equals(java.lang.Object a,
                      double tol)
Compares two double vectors for equality.

Overrides:
equals in class AbstractDoubleVector
Parameters:
a - a double vector.

toString

public java.lang.String toString()
Returns a comma delimited string representing the value of this vector.

Overrides:
toString in class AbstractDoubleVector

toIntegerVector

public AbstractIntegerVector toIntegerVector()
Converts this vector to an integer vector.

Overrides:
toIntegerVector in class AbstractDoubleVector
Returns:
an integer vector.

toComplexVector

public AbstractComplexVector toComplexVector()
Converts this vector to a complex vector.

Overrides:
toComplexVector in class AbstractDoubleVector
Returns:
a complex vector.

getPrimitiveElement

public double getPrimitiveElement(int n)
Returns an element of this vector.

Specified by:
getPrimitiveElement in class AbstractDoubleVector
Parameters:
n - index of the vector element.
Throws:
IllegalDimensionException - If attempting to access an invalid element .

setElement

public void setElement(int n,
                       double x)
Sets the value of a element of this vector.

Specified by:
setElement in class AbstractDoubleVector
Parameters:
n - index of the vector element .
x - a number.
Throws:
IllegalDimensionException - If attempting to access an invalid element .

setAllElements

public void setAllElements(double r)
Sets the value of all elements of the vector.

Overrides:
setAllElements in class AbstractDoubleVector
Parameters:
r - a ring element

norm

public double norm(int n)
Returns the ln-norm.

Overrides:
norm in class AbstractDoubleVector

norm

public double norm()
Returns the l2-norm (magnitude).

Specified by:
norm in interface BanachSpace.Member
Overrides:
norm in class AbstractDoubleVector
Returns:
DOCUMENT ME!

normalize

public void normalize()
Makes the norm of this vector equal to 1.

Overrides:
normalize in class AbstractDoubleVector

infNorm

public double infNorm()
Returns the linfinity-norm.

Overrides:
infNorm in class AbstractDoubleVector

sumSquares

public double sumSquares()
Returns the sum of the squares of the components.

Overrides:
sumSquares in class AbstractDoubleVector
Returns:
DOCUMENT ME!

mass

public double mass()
Returns the mass.

Overrides:
mass in class AbstractDoubleVector
Returns:
DOCUMENT ME!

negate

public AbelianGroup.Member negate()
Returns the negative of this vector.

Specified by:
negate in interface AbelianGroup.Member
Returns:
DOCUMENT ME!

add

public AbelianGroup.Member add(AbelianGroup.Member v)
Returns the addition of this vector and another.

Specified by:
add in interface AbelianGroup.Member
Parameters:
v - a group member
Returns:
DOCUMENT ME!

add

public AbstractDoubleVector add(AbstractDoubleVector v)
Returns the addition of this vector and another.

Overrides:
add in class AbstractDoubleVector
Parameters:
v - a double vector.
Throws:
IllegalDimensionException - If the vectors are different sizes.

add

public DoubleVector add(DoubleVector v)

subtract

public AbelianGroup.Member subtract(AbelianGroup.Member v)
Returns the subtraction of this vector by another.

Specified by:
subtract in interface AbelianGroup.Member
Parameters:
v - a group member
Returns:
DOCUMENT ME!

subtract

public AbstractDoubleVector subtract(AbstractDoubleVector v)
Returns the subtraction of this vector by another.

Overrides:
subtract in class AbstractDoubleVector
Parameters:
v - a double vector.
Throws:
IllegalDimensionException - If the vectors are different sizes.

subtract

public DoubleVector subtract(DoubleVector v)

scalarMultiply

public Module.Member scalarMultiply(Ring.Member x)
Returns the multiplication of this vector by a scalar.

Specified by:
scalarMultiply in interface Module.Member
Parameters:
x - a ring member
Returns:
DOCUMENT ME!

scalarMultiply

public AbstractDoubleVector scalarMultiply(double x)
Returns the multiplication of this vector by a scalar.

Overrides:
scalarMultiply in class AbstractDoubleVector
Parameters:
x - a double.

scalarDivide

public VectorSpace.Member scalarDivide(Field.Member x)
Returns the division of this vector by a scalar.

Specified by:
scalarDivide in interface VectorSpace.Member
Parameters:
x - a field member
Returns:
DOCUMENT ME!

scalarDivide

public AbstractDoubleVector scalarDivide(double x)
Returns the division of this vector by a scalar.

Overrides:
scalarDivide in class AbstractDoubleVector
Parameters:
x - a double.
Throws:
java.lang.ArithmeticException - If divide by zero.

scalarProduct

public double scalarProduct(AbstractDoubleVector v)
Returns the scalar product of this vector and another.

Overrides:
scalarProduct in class AbstractDoubleVector
Parameters:
v - a double vector.
Throws:
IllegalDimensionException - If the vectors are different sizes.

scalarProduct

public double scalarProduct(DoubleVector v)

mapElements

public AbstractDoubleVector mapElements(PrimitiveMapping f)
Applies a function on all the vector components.

Overrides:
mapElements in class AbstractDoubleVector
Parameters:
f - a user-defined function.
Returns:
a double vector.

toPrimitiveArray

public double[] toPrimitiveArray()
Projects the vector to an array.

Overrides:
toPrimitiveArray in class AbstractDoubleVector
Returns:
an double array.

clone

public java.lang.Object clone()
Clone vector into a new vector.

Overrides:
clone in class java.lang.Object
Returns:
the cloned vector.