net.sourceforge.cilib.math
Interface VectorMath

All Known Implementing Classes:
GridLocation, Vector

public interface VectorMath

Interface to define operations associated with Vector mathematics.

Author:
Gary Pampara

Method Summary
 Vector cross(Vector vector)
          Get the cross-product vector based on the current Vector and the given Vector.
 Vector divide(double scalar)
          Divide the elements of the current Vector by the provided scalar.
 double dot(Vector vector)
          Calculate the vector dot product of the current Vector and the given Vector.
 Vector multiply(double scalar)
          Multiply a scalar with each component in the Vector.
 double norm()
          Calculate the norm of this Vector object.
 Vector normalize()
          Create a unit vector from the current Vector.
 Vector plus(Vector vector)
          Adding this Vector to another will result in a resultant Vector.
 Vector subtract(Vector vector)
          Subtract the provided Vector from the current Vector.
 

Method Detail

plus

Vector plus(Vector vector)
Adding this Vector to another will result in a resultant Vector.

Parameters:
vector - The Vector to add to the current one
Returns:
The resultant Vector

subtract

Vector subtract(Vector vector)
Subtract the provided Vector from the current Vector. The result of the subtraction operation is a new Vector instance, maintaining the immutability of the operation.

Parameters:
vector - The Vector to subtract.
Returns:
A new Vector instance representing the result of the operation.

divide

Vector divide(double scalar)
Divide the elements of the current Vector by the provided scalar.

Parameters:
scalar - The value to divide all elements within the Vector by.
Returns:
A new Vector instance containing the result of the operator.

multiply

Vector multiply(double scalar)
Multiply a scalar with each component in the Vector.

Parameters:
scalar - The scalar to multiply in.
Returns:
A new Vector instance containing the result of the operator.

norm

double norm()
Calculate the norm of this Vector object. All the elements must be of type Numeric.

Returns:
The value of the vector norm

normalize

Vector normalize()
Create a unit vector from the current Vector.

Returns:
The created unit vector.

dot

double dot(Vector vector)
Calculate the vector dot product of the current Vector and the given Vector.

Parameters:
vector - The given Vector object with which the vector dot product is to be calculated.
Returns:
The dot product value.

cross

Vector cross(Vector vector)
Get the cross-product vector based on the current Vector and the given Vector. It is important to note that the cross product is only valid and defined for a 3-dimensional vector, if a Vector with more dimensions is provided, an ArithmeticException will be thrown.

Parameters:
vector - The specified Vector with with the cross product operation is to be performed.
Returns:
The orthogonal vector to the current and the specified Vector.
Throws:
ArithmeticException - if vectors are invalid.


Copyright © 2009 CIRG. All Rights Reserved.