Class Vector

java.lang.Object
ch.nolix.base.math.algebra.Vector

public final class Vector extends Object
A Vector is not mutable.
Author:
Silvan Wyss
  • Field Details

    • EMPTY_VECTOR

      public static final Vector EMPTY_VECTOR
  • Method Details

    • fromArray

      public static Vector fromArray(double[] values)
      Parameters:
      values -
      Returns:
      a new Vector with the given values.
    • withValues

      public static Vector withValues(double... values)
      Parameters:
      values -
      Returns:
      a new Vector with the given values.
      Throws:
      RuntimeException - if the given values is null.
    • equals

      public boolean equals(Object object)
      Overrides:
      equals in class Object
    • getEuclidNorm

      public double getEuclidNorm()
      Returns:
      the euclid norm of the current Vector.
    • getManhattanNorm

      public double getManhattanNorm()
      Returns:
      the Manhattan norm of the current Vector.
    • getProduct

      public Vector getProduct(double factor)
      Parameters:
      factor -
      Returns:
      a new Vector that is the product of the current Vector with the given factor.
    • getSize

      public int getSize()
      Returns:
      the size of the current Vector.
    • getSum

      public Vector getSum(Vector vector)
      Parameters:
      vector -
      Returns:
      a new Vector that is the sum of the current Vector and the given vector.
    • getValueAtOneBasedIndex

      public double getValueAtOneBasedIndex(int oneBasedIndex)
      Parameters:
      oneBasedIndex -
      Returns:
      the value of the current Vector at the given oneBasedIndex.
      Throws:
      RuntimeException - if the given oneBasedIndex is not positive or the given oneBasedIndex is bigger than the size of the current Vector.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • hasSameSizeAs

      public boolean hasSameSizeAs(Vector vector)
    • toArray

      public double[] toArray()
      Returns:
      an array with the values of the current Vector
    • toString

      public String toString()
      Overrides:
      toString in class Object