Class ColumnVector


  • public class ColumnVector
    extends Matrix
    From: Java Number Cruncher The Java Programmer's Guide to Numerical Computation by Ronald Mak A column vector.
    • Constructor Detail

      • ColumnVector

        public ColumnVector​(int n)
        Constructor.
        Parameters:
        n - the number of elements
      • ColumnVector

        public ColumnVector​(double[] values)
        Constructor.
        Parameters:
        values - the array of values
    • Method Detail

      • size

        public int size()
        Return this column vector's size.
      • at

        public double at​(int i)
        Return the i'th value of the vector.
        Parameters:
        i - the index
        Returns:
        the value
      • copyValues1D

        public double[] copyValues1D()
        Copy the values of this matrix.
        Returns:
        the copied values
      • set

        protected void set​(double[] values)
        Set this column vector from an array of values.
        Parameters:
        values - the array of values
      • set

        public void set​(int i,
                        double value)
        Set the value of the i'th element.
        Parameters:
        i - the index
        value - the value
      • add

        public ColumnVector add​(ColumnVector cv)
                         throws MatrixException
        Add another column vector to this column vector.
        Parameters:
        cv - the other column vector
        Returns:
        the sum column vector
        Throws:
        numbercruncher.MatrixException - for invalid size
        MatrixException
      • subtract

        public ColumnVector subtract​(ColumnVector cv)
                              throws MatrixException
        Subtract another column vector from this column vector.
        Parameters:
        cv - the other column vector
        Returns:
        the sum column vector
        Throws:
        numbercruncher.MatrixException - for invalid size
        MatrixException
      • norm

        public double norm()
        Compute the Euclidean norm.
        Returns:
        the norm
      • print

        public void print()
        Print the vector values.