Documentation of 'medusa.georgios.enhanced_mcl.Vectors' Java class
Vectors
medusa.georgios.enhanced_mcl

Class Vectors



  • public class Vectors
    extends java.lang.Object
    Static vector manipulation routines for Matlab porting and other numeric operations. The routines work for int and double partly; the class is extended as needed.

    TODO: The question remains whether it makes sense to have a formal IntVector, analoguous to IntMatrix that allows performing search and indexing operations, such as views, etc.

    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static int colwidth 
      static int ndigits 
    • Constructor Summary

      Constructors 
      Constructor and Description
      Vectors() 
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static void add(int[] vec, int scalar)
      add a scalar to the vector
      static int[] cast(double[] vec)
      cast a double[] to an int[]
      static double[] cast(int[] vec)
      cast a double[] to an int[]
      static double[][] chooseElements(double[][] matrix, int[] rows, int[] cols)
      Create a matrix that contains the rows and columns of the argument matrix in the order given by rows and cols
      static double[] chooseElements(double[] vector, int[] keep)
      Create vector that contains the elements of the argument in the order as given by keep
      static int[][] chooseElements(int[][] matrix, int[] rows, int[] cols)
      Create a matrix that contains the rows and columns of the argument matrix in the order given by rows and cols
      static int[] chooseElements(int[] vector, int[] keep)
      Create vector that contains the elements of the argument in the order as given by keep
      static double[] concat(double[] x, double[] y) 
      static double[] concat(double[] x, double[] y, double[] z)
      w = [x y z]
      static double[] copy(double[] source)
      copies a the source to the destination
      static int[] copy(int[] source)
      copies a the source to the destination
      static double[] cumsum(double[] vec)
      cumulative sum of the elements, starting at element 0.
      static int[] find(int[] vec, int val)
      find indices with val
      static double[][] increaseSize(double[][] matrix, int morerows, int morecols)
      Create new matrix of larger size and data of the argument.
      static double[] increaseSize(double[] vector, int moreelements)
      Create new vector of larger size and data of the argument.
      static int[][] increaseSize(int[][] matrix, int morerows, int morecols)
      Create new matrix of larger size and data of the argument.
      static int[] increaseSize(int[] vector, int moreelements)
      Create new vector of larger size and data of the argument.
      static double max(double[] vec)
      maximum value in vec
      static int max(int[] vec)
      maximum value in vec
      static double min(double[] vec)
      minimum value in vec
      static int min(int[] vec)
      minimum value in vec
      static double[] mult(double[] ds, double d)
      multiplicates the vector with a scalar.
      static double mult(double[] ds, double[] dt)
      multiplicates the vector with a vector (inner product).
      static int[] ones(int len) 
      static double[] ones(int len, double factor) 
      static int[] ones(int len, int factor) 
      static java.lang.String print(double[] x)
      prints a double representation of the vector.
      static java.lang.String print(double[][] x)
      prints a double representation of an array.
      static java.lang.String print(int[] x)
      prints a double representation of the vector.
      static java.lang.String print(int[][] x)
      prints a double representation of an array.
      static double[] range(double start, double end) 
      static double[] range(double start, double end, double step)
      create sequence [start : step : end] of double values.
      static int[] range(int start, int end) 
      static int[] range(int start, int end, int step) 
      static int[] rangeComplement(int[] set, int length)
      return the complement of the sorted subset of the set 0:length-1 in Matlab notation
      static double[] removeElement(double[] vector, int element)
      Create new vector with data of the argument and removed element.
      static int[] removeElement(int[] vector, int element)
      Create new vector with data of the argument and removed element.
      static double[][] removeElements(double[][] matrix, int[] rows, int[] cols)
      Create new matrix with data of the argument and removed rows and columns.
      static double[] removeElements(double[] vector, int[] elements)
      Create new vector with data of the argument and removed elements.
      static int[][] removeElements(int[][] matrix, int[] rows, int[] cols)
      Create new matrix with data of the argument and removed rows and columns.
      static int[] removeElements(int[] vector, int[] elements)
      Create new vector with data of the argument and removed elements.
      static void setSubVector(int[] vec, int[] indices, int replacement)
      set the elements of vec at indices with the replacement.
      static void setSubVector(int[] vec, int[] indices, int[] replacements)
      set the elements of vec at indices with the respective replacements.
      static int[] setSubVectorCopy(int[] vec, int[] indices, int[] replacements)
      set the elements of a copy of vec at indices with the respective replacements.
      static double[] subVector(double[] vec, int[] indices)
      returns a copy of the vector elements with the given indices in the original vector.
      static double[] subVector(double[] vec, int start, int end) 
      static int[] subVector(int[] vec, int[] indices)
      returns a copy of the vector elements with the given indices in the original vector.
      static double sum(double[] vec)
      sum the elements of vec
      static int sum(int[] vec)
      sum the elements of vec
      static double[][] transpose(double[][] mat)
      transpose the matrix
      static int[][] transpose(int[][] mat)
      transpose the matrix
      static double[] zeros(int len) 
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • ndigits

        public static int ndigits
      • colwidth

        public static int colwidth
    • Constructor Detail

      • Vectors

        public Vectors()
    • Method Detail

      • range

        public static int[] range(int start,
                                  int end,
                                  int step)
        Parameters:
        start -
        end -
        step -
        Returns:
        [start : step : end]
      • range

        public static int[] range(int start,
                                  int end)
        Parameters:
        start -
        end -
        Returns:
        [start : end]
      • range

        public static double[] range(double start,
                                     double end,
                                     double step)
        create sequence [start : step : end] of double values. TODO: check precision.
        Parameters:
        start - double value of start, if integer, use "1.0" notation.
        end - double value of end, if integer, use "1.0" notation.
        step - double value of step size
        Returns:
      • range

        public static double[] range(double start,
                                     double end)
        Parameters:
        start -
        end -
        Returns:
        [start : end]
      • sum

        public static double sum(double[] vec)
        sum the elements of vec
        Parameters:
        vec -
        Returns:
      • sum

        public static int sum(int[] vec)
        sum the elements of vec
        Parameters:
        vec -
        Returns:
      • cumsum

        public static double[] cumsum(double[] vec)
        cumulative sum of the elements, starting at element 0.
        Parameters:
        vec -
        Returns:
        vector containing the cumulative sum of the elements of vec
      • max

        public static int max(int[] vec)
        maximum value in vec
        Parameters:
        vec -
        Returns:
      • max

        public static double max(double[] vec)
        maximum value in vec
        Parameters:
        vec -
        Returns:
      • min

        public static int min(int[] vec)
        minimum value in vec
        Parameters:
        vec -
        Returns:
      • min

        public static double min(double[] vec)
        minimum value in vec
        Parameters:
        vec -
        Returns:
      • concat

        public static double[] concat(double[] x,
                                      double[] y)
        Parameters:
        x -
        y -
        Returns:
        [x y]
      • concat

        public static double[] concat(double[] x,
                                      double[] y,
                                      double[] z)
        w = [x y z]
        Parameters:
        x -
        y -
        Returns:
        [x y z]
      • increaseSize

        public static double[] increaseSize(double[] vector,
                                            int moreelements)
        Create new vector of larger size and data of the argument.
        Parameters:
        vector - source array
        moreelements - number of elements to add
        Returns:
        larger vector
      • increaseSize

        public static double[][] increaseSize(double[][] matrix,
                                              int morerows,
                                              int morecols)
        Create new matrix of larger size and data of the argument.
        Parameters:
        matrix -
        more - rows
        more - cols
        Returns:
        larger matrix
      • removeElement

        public static double[] removeElement(double[] vector,
                                             int element)
        Create new vector with data of the argument and removed element.
        Parameters:
        vector -
        element -
        Returns:
        shorter vector
      • removeElements

        public static double[][] removeElements(double[][] matrix,
                                                int[] rows,
                                                int[] cols)
        Create new matrix with data of the argument and removed rows and columns.
        Parameters:
        matrix -
        rows - ordered vector of rows to remove
        cols - ordered vector of cols to remove
        Returns:
        smaller matrix
      • removeElements

        public static double[] removeElements(double[] vector,
                                              int[] elements)
        Create new vector with data of the argument and removed elements.
        Parameters:
        vector -
        elements - ordered elements to remove
        Returns:
        smaller vector
      • rangeComplement

        public static int[] rangeComplement(int[] set,
                                            int length)
        return the complement of the sorted subset of the set 0:length-1 in Matlab notation
        Parameters:
        set - sorted set of elements < length
        length - of superset of set and its returned complement
        Returns:
      • chooseElements

        public static double[][] chooseElements(double[][] matrix,
                                                int[] rows,
                                                int[] cols)
        Create a matrix that contains the rows and columns of the argument matrix in the order given by rows and cols
        Parameters:
        matrix -
        rows -
        cols -
        Returns:
      • chooseElements

        public static double[] chooseElements(double[] vector,
                                              int[] keep)
        Create vector that contains the elements of the argument in the order as given by keep
        Parameters:
        vector -
        keep -
        Returns:
      • increaseSize

        public static int[] increaseSize(int[] vector,
                                         int moreelements)
        Create new vector of larger size and data of the argument.
        Parameters:
        vector - source array
        moreelements - number of elements to add
        Returns:
        larger vector
      • increaseSize

        public static int[][] increaseSize(int[][] matrix,
                                           int morerows,
                                           int morecols)
        Create new matrix of larger size and data of the argument.
        Parameters:
        matrix -
        more - rows
        more - cols
        Returns:
        larger matrix
      • removeElement

        public static int[] removeElement(int[] vector,
                                          int element)
        Create new vector with data of the argument and removed element.
        Parameters:
        vector -
        element -
        Returns:
        shorter vector
      • removeElements

        public static int[][] removeElements(int[][] matrix,
                                             int[] rows,
                                             int[] cols)
        Create new matrix with data of the argument and removed rows and columns.
        Parameters:
        matrix -
        rows - ordered vector of rows to remove
        cols - ordered vector of cols to remove
        Returns:
        smaller matrix
      • removeElements

        public static int[] removeElements(int[] vector,
                                           int[] elements)
        Create new vector with data of the argument and removed elements.
        Parameters:
        vector -
        elements - ordered elements to remove
        Returns:
        smaller vector
      • chooseElements

        public static int[][] chooseElements(int[][] matrix,
                                             int[] rows,
                                             int[] cols)
        Create a matrix that contains the rows and columns of the argument matrix in the order given by rows and cols
        Parameters:
        matrix -
        rows -
        cols -
        Returns:
      • chooseElements

        public static int[] chooseElements(int[] vector,
                                           int[] keep)
        Create vector that contains the elements of the argument in the order as given by keep
        Parameters:
        vector -
        keep -
        Returns:
      • print

        public static java.lang.String print(double[] x)
        prints a double representation of the vector.
        Parameters:
        x -
        Returns:
      • print

        public static java.lang.String print(double[][] x)
        prints a double representation of an array.
        Parameters:
        x -
        Returns:
      • print

        public static java.lang.String print(int[] x)
        prints a double representation of the vector.
        Parameters:
        x -
        Returns:
      • print

        public static java.lang.String print(int[][] x)
        prints a double representation of an array.
        Parameters:
        x -
        Returns:
      • ones

        public static double[] ones(int len,
                                    double factor)
        Parameters:
        len -
        factor -
        Returns:
        factor * ones(1, len);
      • ones

        public static int[] ones(int len,
                                 int factor)
        Parameters:
        len -
        factor -
        Returns:
        factor * ones(1, len);
      • zeros

        public static double[] zeros(int len)
        Parameters:
        len -
        Returns:
        zeros(1, len)
      • ones

        public static int[] ones(int len)
        Parameters:
        len -
        Returns:
        ones(1, len)
      • cast

        public static int[] cast(double[] vec)
        cast a double[] to an int[]
        Parameters:
        vec -
        Returns:
      • cast

        public static double[] cast(int[] vec)
        cast a double[] to an int[]
        Parameters:
        vec -
        Returns:
      • find

        public static int[] find(int[] vec,
                                 int val)
        find indices with val
        Parameters:
        vec -
        val -
        Returns:
        vector with 0-based indices.
      • subVector

        public static double[] subVector(double[] vec,
                                         int[] indices)
        returns a copy of the vector elements with the given indices in the original vector.
        Parameters:
        indices -
        Returns:
      • subVector

        public static int[] subVector(int[] vec,
                                      int[] indices)
        returns a copy of the vector elements with the given indices in the original vector.
        Parameters:
        cols -
        Returns:
      • subVector

        public static double[] subVector(double[] vec,
                                         int start,
                                         int end)
        Parameters:
        weights -
        i -
        j -
        Returns:
      • setSubVector

        public static void setSubVector(int[] vec,
                                        int[] indices,
                                        int[] replacements)
        set the elements of vec at indices with the respective replacements. TODO: implement views as in the colt library
        Parameters:
        vec -
        indices -
        replacements -
      • setSubVector

        public static void setSubVector(int[] vec,
                                        int[] indices,
                                        int replacement)
        set the elements of vec at indices with the replacement. TODO: implement views as in the colt library
        Parameters:
        vec -
        indices -
        replacement -
      • add

        public static void add(int[] vec,
                               int scalar)
        add a scalar to the vector
        Parameters:
        vec -
        scalar -
      • setSubVectorCopy

        public static int[] setSubVectorCopy(int[] vec,
                                             int[] indices,
                                             int[] replacements)
        set the elements of a copy of vec at indices with the respective replacements. TODO: implement views as in the colt library
        Parameters:
        vec -
        indices -
        replacements -
        Returns:
        the copied vector with the replacements;
      • copy

        public static double[] copy(double[] source)
        copies a the source to the destination
        Parameters:
        alpha -
        Returns:
      • copy

        public static int[] copy(int[] source)
        copies a the source to the destination
        Parameters:
        alpha -
        Returns:
      • mult

        public static double[] mult(double[] ds,
                                    double d)
        multiplicates the vector with a scalar. The argument is modified.
        Parameters:
        ds -
        d -
        Returns:
      • mult

        public static double mult(double[] ds,
                                  double[] dt)
        multiplicates the vector with a vector (inner product). The argument is not modified.
        Parameters:
        ds -
        d -
        Returns:
      • transpose

        public static double[][] transpose(double[][] mat)
        transpose the matrix
        Parameters:
        mat -
        Returns:
      • transpose

        public static int[][] transpose(int[][] mat)
        transpose the matrix
        Parameters:
        mat -
        Returns:

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.