org.apache.commons.math3.geometry

## Interface Vector<S extends Space>

Type Parameters:
  `S` - Type of the space.

All Superinterfaces:
  Serializable

All Known Implementing Classes:
  Vector1D, Vector2D, Vector3D

    public interface Vector<S extends Space>
    extends Serializable

This interface represents a generic vector in a vectorial space or a point in an affine space.

Since:
  3.0
Version:
  $Id: Vector.java 1416643 2012-12-03 19:37:14Z tn $
See Also:
  `Space`, `Vector`

### Method Summary

Methods
`Vector<S>` `add(double factor, Vector<S> v)` Add a scaled vector to the instance.
`Vector<S>` `add(Vector<S> v)` Add a vector to the instance.
`double` `distance(Vector<S> v)` Compute the distance between the instance and another vector according to the L2 norm.
`double` `distance1(Vector<S> v)` Compute the distance between the instance and another vector according to the L1 norm.
`double` `distanceInf(Vector<S> v)` Compute the distance between the instance and another vector according to the L∞ norm.
`double` `distanceSq(Vector<S> v)` Compute the square of the distance between the instance and another vector.
`double` `dotProduct(Vector<S> v)` Compute the dot-product of the instance and another vector.
`double` `getNorm()` Get the L2 norm for the vector.
`double` `getNorm1()` Get the L1 norm for the vector.
`double` `getNormInf()` Get the L∞ norm for the vector.
`double` `getNormSq()` Get the square of the norm for the vector.
`Space` `getSpace()` Get the space to which the vector belongs.
`Vector<S>` `getZero()` Get the null vector of the vectorial space or origin point of the affine space.
`boolean` `isInfinite()` Returns true if any coordinate of this vector is infinite and none are NaN; false otherwise
`boolean` `isNaN()` Returns true if any coordinate of this vector is NaN; false otherwise
`Vector<S>` `negate()` Get the opposite of the instance.
`Vector<S>` `normalize()` Get a normalized vector aligned with the instance.
`Vector<S>` `scalarMultiply(double a)` Multiply the instance by a scalar.
`Vector<S>` `subtract(double factor, Vector<S> v)` Subtract a scaled vector from the instance.
`Vector<S>` `subtract(Vector<S> v)` Subtract a vector from the instance.
`String` `toString(NumberFormat format)` Get a string representation of this vector.

### Method Detail

#### getSpace

    Space getSpace()

Get the space to which the vector belongs.

Returns:
  containing space

#### getZero

    Vector<S> getZero()

Get the null vector of the vectorial space or origin point of the affine space.

Returns:
  null vector of the vectorial space or origin point of the affine space

#### getNorm1

    double getNorm1()

Get the L1 norm for the vector.

Returns:
  L1 norm for the vector

#### getNorm

    double getNorm()

Get the L2 norm for the vector.

Returns:
  Euclidean norm for the vector

#### getNormSq

    double getNormSq()

Get the square of the norm for the vector.

Returns:
  square of the Euclidean norm for the vector

#### getNormInf

    double getNormInf()

Get the L∞ norm for the vector.

Returns:
  L∞ norm for the vector

#### add

    Vector<S> add(Vector<S> v)

Add a vector to the instance.

Parameters:
  `v` - vector to add
Returns:
  a new vector

#### add

    Vector<S> add(double factor,
                Vector<S> v)

Add a scaled vector to the instance.

Parameters:
  `factor` - scale factor to apply to v before adding it
  `v` - vector to add
Returns:
  a new vector

#### subtract

    Vector<S> subtract(Vector<S> v)

Subtract a vector from the instance.

Parameters:
  `v` - vector to subtract
Returns:
  a new vector

#### subtract

    Vector<S> subtract(double factor,
                     Vector<S> v)

Subtract a scaled vector from the instance.

Parameters:
  `factor` - scale factor to apply to v before subtracting it
  `v` - vector to subtract
Returns:
  a new vector

#### negate

    Vector<S> negate()

Get the opposite of the instance.

Returns:
  a new vector which is opposite to the instance

#### normalize

    Vector<S> normalize()
                                      throws MathArithmeticException

Get a normalized vector aligned with the instance.

Returns:
  a new normalized vector
Throws:
  `MathArithmeticException` - if the norm is zero

#### scalarMultiply

    Vector<S> scalarMultiply(double a)

Multiply the instance by a scalar.

Parameters:
  `a` - scalar
Returns:
  a new vector

#### isNaN

    boolean isNaN()

Returns true if any coordinate of this vector is NaN; false otherwise

Returns:
  true if any coordinate of this vector is NaN; false otherwise

#### isInfinite

    boolean isInfinite()

Returns true if any coordinate of this vector is infinite and none are NaN; false otherwise

Returns:
  true if any coordinate of this vector is infinite and none are NaN; false otherwise

#### distance1

    double distance1(Vector<S> v)

Compute the distance between the instance and another vector according to the L1 norm.

Calling this method is equivalent to calling: `q.subtract(p).getNorm1()` except that no intermediate vector is built

Parameters:
  `v` - second vector
Returns:
  the distance between the instance and p according to the L1 norm

#### distance

    double distance(Vector<S> v)

Compute the distance between the instance and another vector according to the L2 norm.

Calling this method is equivalent to calling: `q.subtract(p).getNorm()` except that no intermediate vector is built

Parameters:
  `v` - second vector
Returns:
  the distance between the instance and p according to the L2 norm

#### distanceInf

    double distanceInf(Vector<S> v)

Compute the distance between the instance and another vector according to the L∞ norm.

Calling this method is equivalent to calling: `q.subtract(p).getNormInf()` except that no intermediate vector is built

Parameters:
  `v` - second vector
Returns:
  the distance between the instance and p according to the L∞ norm

#### distanceSq

    double distanceSq(Vector<S> v)

Compute the square of the distance between the instance and another vector.

Calling this method is equivalent to calling: `q.subtract(p).getNormSq()` except that no intermediate vector is built

Parameters:
  `v` - second vector
Returns:
  the square of the distance between the instance and p

#### dotProduct

    double dotProduct(Vector<S> v)

Compute the dot-product of the instance and another vector.

Parameters:
  `v` - second vector
Returns:
  the dot product this.v

#### toString

    String toString(NumberFormat format)

Get a string representation of this vector.

Parameters:
  `format` - the custom format for components
Returns:
  a string representation of this vector