## Class Vector

    java.lang.Object
      Vector

     class Vector

extends Object

This class introduces vectors and enables basic operations with them. The coordinates are stored as a field of `Fraction`s.

Since:
  2014-04-01
Version:
  1.0
Author:
  Pavel Sikora <pavelsikora@mail.muni.cz>

Constructor Summary
`Vector()` Constructs a null vector of dimension 0.
`Vector(Fraction[] V, int d)` Constructs a vector from a field of `Fraction`s.
`Vector(int d)` Constructs a zero vector of a given dimension.
`Vector(Point B)` Constructs a vector from a point (initial point will be the origin).
`Vector(Point A, Point B)` Constructs a vector from two given points.

Method Summary
`(package private) Vector` `add(Vector A)` Adds another vector to this vector.
`(package private) Cyclometric` `angleDirectionVectors(Vector W)` Calculates the angle of two direction vectors of lines (ie. the resulting angle will be from 0 to π/2).
`(package private) void` `copy(Vector I)` Copies another vector onto this vector.
`(package private) static Vector[]` `generateRandomParallelVectors(int DIM)` Generates two random parallel vectors of given dimension.
`(package private) static Vector[]` `generateRandomPerpendicularVectors(int DIM)` Generates two random perpendicular vectors of given dimension.
`(package private) static Vector[]` `generateRandomVectorsWithAngle30(int DIM)` Generates two random vectors of given dimension whose angle is π/6.
`(package private) static Vector[]` `generateRandomVectorsWithAngle45(int DIM)` Generates two random vectors of given dimension whose angle is π/4.
`(package private) static Vector[]` `generateRandomVectorsWithAngle60(int DIM)` Generates two random vectors of given dimension whose angle is π/3.
`(package private) static Vector[]` `generateRandomVectorsWithGivenAngle(PiFraction angle, int DIM)` Generates two random vectors, while the angle of the vectors will be one of 0, π/6, π/4, π/3, or π/2.
`(package private) Fraction` `get(int i)` The getter of this class - returns the value of a given coordinate.
`(package private) int` `getDim()` Gets the dimensions of the vector.
`(package private) boolean` `isEqual(Vector C)` Checks if two vectors are equal.
`(package private) boolean` `isZeroVector()` Checks whether or not this vector is a zero vector.
`(package private) SquareRootFraction` `length()` Computes length of this vector.
`(package private) SquareRootFraction` `length(char label, boolean verbose)` Computes length of this vector.
`(package private) Vector` `multiply(Fraction F)` Multiplies this vector by a scalar.
`(package private) Vector` `opposite()` Finds ppposite vector to this vector.
`(package private) Vector` `orthogonalComponent(Matrix W)` Finds the orthogonal component of the vector onto a given difference space.
`(package private) Vector` `orthogonalComponent(Matrix W, boolean verbose)` Finds the orthogonal component of the vector onto a given difference space.
`(package private) Vector` `orthogonalProjection(Matrix W)` Finds the orthogonal projection of this vector onto a given difference space.
`(package private) Vector` `orthogonalProjection(Matrix W, boolean verbose)` Finds the orthogonal projection of this vector onto a given difference space.
`(package private) Fraction` `scalarProduct(Vector F)` Computes scalar product of two vectors.
`(package private) SquareRootFraction` `scalarProductNorm(Vector F)` Computes scalar product of two vectors after normalizing them.
`(package private) void` `set(Fraction F, int i)` The setter of this class - sets given coordinate to a given value.
`(package private) Vector` `subtract(Vector S)` Subtracts another vector from this vector.
`(package private) Matrix` `toMatrixColumn()` Converts the vector to a 1-column matrix.
`(package private) Matrix` `toMatrixRow()` Converts the vector to a 1-row matrix.
`(package private) String` `toTeX()` Prints this vector formatted as TeX code.
`(package private) String` `toText()` Prints this vector formatted as text.

Methods inherited from class
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Vector

    Vector()

  Constructs a null vector of dimension 0.

### Vector

    Vector(Fraction[] V,
           int d)

  Constructs a vector from a field of `Fraction`s.

  Parameters:
    `V` - field of `Fraction`s, containing the vector's coordinates
    `d` - dimension of the vector, ie. number of its coordinates

### Vector

    Vector(int d)

  Constructs a zero vector of a given dimension.

  Parameters:
    `d` - dimension of the vector, ie. number of its coordinates

### Vector

    Vector(Point B)

  Constructs a vector from a point (initial point will be the origin).

  Parameters:
    `B` - terminal point
  Throws:
    `UnsupportedOperationException` - Throws an exception if the points don't have equal dimension.

### Vector

    Vector(Point A,
           Point B)

  Constructs a vector from two given points.

  Parameters:
    `A` - initial point
    `B` - terminal point
  Throws:
    `UnsupportedOperationException` - Throws an exception if the points don't have equal dimension.

Method Detail

### add

    Vector add(Vector A)

  Adds another vector to this vector.

  Parameters:
    `A` - addend vector
  Throws:
    `UnsupportedOperationException` - Throws an exception if the vectors don't have equal dimension.

### angleDirectionVectors

    Cyclometric angleDirectionVectors(Vector W)

  Calculates the angle of two direction vectors of lines (ie. the resulting angle will be from 0 to π/2).

  Parameters:
    `V` - the other vector
  Returns:
    if the angle is any of 0, π/6, π/4, π/3, π/2, the returned object is a `PiFraction`; otherwise, the retuned object is a double

### copy

    void copy(Vector I)

  Copies another vector onto this vector. This is the correct way of assigning vectors, not by `=`.

  Parameters:
    `I` - the image vector

### generateRandomParallelVectors

    static Vector[] generateRandomParallelVectors(int DIM)

  Generates two random parallel vectors of given dimension.

  Parameters:
    `DIM` - dimension of the vectors
  Returns:
    vectors with desired angle
  Throws:
    `UnsupportedOperationException` - if DIM is zero

### generateRandomPerpendicularVectors

    static Vector[] generateRandomPerpendicularVectors(int DIM)

  Generates two random perpendicular vectors of given dimension.

  Returns:
    vectors with desired angle
  Throws:
    `UnsupportedOperationException` - if DIM is zero

### generateRandomVectorsWithAngle30

    static Vector[] generateRandomVectorsWithAngle30(int DIM)

  Generates two random vectors of given dimension whose angle is π/6.

  Returns:
    vectors with desired angle
  Throws:
    `UnsupportedOperationException` - if DIM is less than three

### generateRandomVectorsWithAngle45

    static Vector[] generateRandomVectorsWithAngle45(int DIM)

  Generates two random vectors of given dimension whose angle is π/4.

  Returns:
    vectors with desired angle
  Throws:
    `UnsupportedOperationException` - if DIM is less than two

### generateRandomVectorsWithAngle60

    static Vector[] generateRandomVectorsWithAngle60(int DIM)

  Generates two random vectors of given dimension whose angle is π/3.

  Returns:
    vectors with desired angle
  Throws:
    `UnsupportedOperationException` - if DIM is less than three

### generateRandomVectorsWithGivenAngle

    static Vector[] generateRandomVectorsWithGivenAngle(PiFraction angle,
                                                        int DIM)

  Generates two random vectors, while the angle of the vectors will be one of 0, π/6, π/4, π/3, or π/2.

  Parameters:
    `angle` - the desired angle of vectors
  Returns:
    vectors with desired angle
  Throws:
    `UnsupportedOperationException` - if angle is none of 0, π/6, π/4, π/3, or π/2

### get

    Fraction get(int i)

  The getter of this class - returns the value of a given coordinate.

  Parameters:
    `i` - the index of desired coordinate
  Returns:
    the `i`th coordinate value (a `Fraction`)
  Throws:
    `IndexOutOfBoundsException` - Throws an exception if the index isn't of <1,dimension of the vector>.

### getDim

    int getDim()

  Gets the dimensions of the vector.

  Returns:
    dimension of the vector

### isEqual

    boolean isEqual(Vector C)

  Checks if two vectors are equal.

  Parameters:
    `C` - comparand vector
  Returns:
    true if this vector is equal to the comparand, false otherwise
  Throws:
    `UnsupportedOperationException` - Throws an exception if the vectors don't have equal dimension.

### isZeroVector

    boolean isZeroVector()

  Checks whether or not this vector is a zero vector.

  Returns:
    true if this vector is a zero vector or a null vector, false otherwise

### length

    SquareRootFraction length()

  Computes length of this vector. This method doesn't “talk” (creates no text nor TeX output).

  Returns:
    length of this vector

### length

    SquareRootFraction length(char label,
                              boolean verbose)

  Computes length of this vector.

  Parameters:
    `label` - label of the matrix
    `verbose` - determines, if the method “talks” (creates any text and TeX output)
  Returns:
    length of this vector

### multiply

    Vector multiply(Fraction F)

  Multiplies this vector by a scalar.

  Parameters:
    `F` - factor
  Returns:
    `F`-multiple of this vector

### opposite

    Vector opposite()

  Finds ppposite vector to this vector.

  Returns:
    the opposite vector

### orthogonalComponent

    Vector orthogonalComponent(Matrix W)

  Finds the orthogonal component of the vector onto a given difference space. This method doesn't “talk” (creates no text nor TeX output).

  Parameters:
    `W` - difference space onto which we project the vector
  Returns:
    the orthogonal component of this vector onto a given difference space

### orthogonalComponent

    Vector orthogonalComponent(Matrix W,
                               boolean verbose)

  Finds the orthogonal component of the vector onto a given difference space.

  Parameters:
    `W` - difference space onto which we project the vector
    `verbose` - determines, if the method “talks” (creates any text and TeX output)
  Returns:
    the orthogonal component of this vector onto a given difference space

### orthogonalProjection

    Vector orthogonalProjection(Matrix W)

  Finds the orthogonal projection of this vector onto a given difference space. This method doesn't “talk” (creates no text nor TeX output).

  Parameters:
    `W` - difference space onto which we project the vector
  Returns:
    the orthogonal projection of this vector onto a given difference space

### orthogonalProjection

    Vector orthogonalProjection(Matrix W,
                                boolean verbose)

  Finds the orthogonal projection of this vector onto a given difference space.

  Parameters:
    `W` - difference space onto which we project the vector
    `verbose` - determines, if the method “talks” (creates any text and TeX output)
  Returns:
    the orthogonal projection of this vector onto a given difference space

### scalarProduct

    Fraction scalarProduct(Vector F)

  Computes scalar product of two vectors.

  Parameters:
    `F` - factor vector
  Throws:
    `UnsupportedOperationException` - Throws an exception if the vectors don't have equal dimension.

### scalarProductNorm

    SquareRootFraction scalarProductNorm(Vector F)

  Computes scalar product of two vectors after normalizing them.

  Parameters:
    `F` - factor vector
  Throws:
    `UnsupportedOperationException` - Throws an exception if the vectors don't have equal dimension.

### set

    void set(Fraction F,
             int i)

  The setter of this class - sets given coordinate to a given value.

  Parameters:
    `F` - the `i`th coordinate desired value (a `Fraction`)
    `i` - the index of desired coordinate
  Throws:
    `IndexOutOfBoundsException` - Throws an exception if the index isn't of <1,dimension of the vector>.

### subtract

    Vector subtract(Vector S)

  Subtracts another vector from this vector.

  Parameters:
    `S` - subtrahend vector
  Throws:
    `UnsupportedOperationException` - Throws an exception if the vectors don't have equal dimension.

### toMatrixColumn

    Matrix toMatrixColumn()

  Converts the vector to a 1-column matrix.

### toMatrixRow

    Matrix toMatrixRow()

  Converts the vector to a 1-row matrix.

### toTeX

    String toTeX()

  Prints this vector formatted as TeX code.

  Returns:
    TeX code for this vector

### toText

    String toText()

  Prints this vector formatted as text.

  Returns:
    plain text description of this vector; it will begin with `(` and end with `)`