Class Vector

  • Direct Known Subclasses:
    Vector3, Vector4

    public class Vector
    extends Matrix
    This class implements a n-dimensional vector.
    • Constructor Detail

      • Vector

        public Vector​(int n,
                      boolean row)
        Creates a new Vector with n dimensions. Each entry is of type double.
        Parameters:
        n - Dimension
        row - true: vector has n rows and one column, false: vector has n columns and one row.
      • Vector

        public Vector​(int n)
        Creates a new Vector with n dimensions. The Vector has one row and n columns.
        Parameters:
        n - Dimension
    • Method Detail

      • getSize

        public int getSize()
        Returns the size of a Vector.
        Returns:
        Dimension of the Vector.
      • set

        public boolean set​(int i,
                           double value)
        Set one element in a Vector.
        Parameters:
        i - Element number (1..n)
        value - Value to set
        Returns:
        false if specified position is not within the vector.
      • get

        public double get​(int i)
        Read an entry in a Vector. Returns Double.NaN if specified position is not within the Vector.
        Parameters:
        i - Element number (1..n)
        Returns:
        Entry at i or Double.NaN if specified position is not within the vector.
      • add

        public boolean add​(Vector left,
                           Vector right,
                           boolean ignoreOrientation)
        Adds two vectors and stores the result in this instance. Returns false if the dimensions of the involved vectors do not fit.
        Parameters:
        left - First input vector
        right - Second input vector
        ignoreOrientation - If true the orientation (row vector - column vector) is not checked
        Returns:
        false if dimensions of the involved vectors do not fit.
      • dot

        public double dot​(Vector right)
        Calculates the dot products of a vector with this instance. Returns Double.NaN if the dimensions of the involved vectors do not fit.
        Parameters:
        right - Input vector
        Returns:
        Dot product or Double.NaN if dimensions of the involved vectors do not fit.