: Class AlgebraicVector

cas
Class AlgebraicVector

java.lang.Object
  |
  +--cas.Tuple
        |
        +--cas.AlgebraicVector
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
AlgebraicVector3D

public class AlgebraicVector
extends Tuple
implements java.io.Serializable

A class representing the abstract entity "n dimensional vector". Data format is double.

Author:
Ziv Yaniv
See Also:
Serialized Form

Fields inherited from class cas.Tuple
data
 
Constructor Summary
AlgebraicVector(AlgebraicVector v)
          Copy constructor, create a vector according to the given vector.
AlgebraicVector(double[] data)
          Create a vector according to the given double array.
AlgebraicVector(int n)
          Create a vector of the given size, with all entries initialized to zero.
AlgebraicVector(int n, double val)
          Create a vector of the given size, with all entries initialized to the given value.
AlgebraicVector(Tuple t)
          Create a vector according to the given tuple.
 
Method Summary
 double angle(AlgebraicVector v)
          Compute the angle between this vector and the given vector.
 double dot(AlgebraicVector v)
          Computes the dot product between this vector and the given vector.
 void normalize()
          Normalize this vector, make this vector a unit vector.
 void normalize(AlgebraicVector v)
          Normalize the given vector and place the result in this vector.
 double normL1()
          Compute the L1 norm of this vector.
 double normL2()
          Compute the L2 norm of this vector.
 double normL2Squared()
          Compute the squared L2 norm of this vector.
 double normLinf()
          Compute the Linfinity norm of this vector.
 
Methods inherited from class cas.Tuple
add, add, clamp, clamp, div, div, equals, getDimension, interpolate, interpolate, max, min, mul, mul, negate, negate, scale, scale, set, set, set, sub, sub, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AlgebraicVector

public AlgebraicVector(int n)
Create a vector of the given size, with all entries initialized to zero.
Parameters:
n - The dimensionality of the point.

AlgebraicVector

public AlgebraicVector(int n,
                       double val)
Create a vector of the given size, with all entries initialized to the given value.
Parameters:
n - The dimensionality of the vector.
val - The value all point entries.

AlgebraicVector

public AlgebraicVector(double[] data)
Create a vector according to the given double array.
Parameters:
data - The vector will contain entries as specified by the given array.

AlgebraicVector

public AlgebraicVector(AlgebraicVector v)
Copy constructor, create a vector according to the given vector.
Parameters:
v - Create a copy of this vector.

AlgebraicVector

public AlgebraicVector(Tuple t)
Create a vector according to the given tuple.
Parameters:
t - Create the vector according to this tuple.
See Also:
Tuple
Method Detail

angle

public double angle(AlgebraicVector v)
Compute the angle between this vector and the given vector. The result is in the range [0,pi].
Parameters:
v - Compute the angle to this vector.
Returns:
Returns the angle between the vectors, in the range [0,pi].

dot

public double dot(AlgebraicVector v)
Computes the dot product between this vector and the given vector.
Parameters:
v - Compute the dot product with this vector.
Returns:
Returns the dot product.

normL2Squared

public double normL2Squared()
Compute the squared L2 norm of this vector.
Returns:
Returns the squared L2 norm of the vector.

normL2

public double normL2()
Compute the L2 norm of this vector.
Returns:
Returns the L2 norm of the vector.

normL1

public double normL1()
Compute the L1 norm of this vector.
Returns:
Returns the L1 norm of the vector.

normLinf

public double normLinf()
Compute the Linfinity norm of this vector.
Returns:
Returns the Linfinity norm of the vector.

normalize

public void normalize()
Normalize this vector, make this vector a unit vector.

normalize

public void normalize(AlgebraicVector v)
Normalize the given vector and place the result in this vector.
Parameters:
v - Set the vector to the normalized form of the given vector, v.