Class MatrixUtils


  • public class MatrixUtils
    extends Object
    These are the utility functions to apply to matrices.
    • Method Detail

      • sum

        public static double sum​(MatrixTable A)
        Get the sum of all elements in the given matrix.
        Parameters:
        A - the matrix
        Returns:
        the sum of all elements
      • rowSums

        public static double[] rowSums​(MatrixTable A)
        Get the row sums. That is, the first element in the output array equals to the sum of the entries in the first row of the input matrix, so on and so forth. So, the number of entries in the output equals to the number of rows in the input matrix.
        Parameters:
        A - a matrix
        Returns:
        the row sums
      • rowSumVector

        public static Vector rowSumVector​(MatrixTable A)
        Get the row sum vector of a given matrix.
        Parameters:
        A - the matrix
        Returns:
        the row sum vector
      • colSums

        public static double[] colSums​(MatrixTable A)
        Get the column sums. That is, the first element in the output array equals to the sum of the entries in the first column of the input matrix, so on and so forth. So, the number of entries in the output equals to the number of columns in the input matrix.
        Parameters:
        A - a matrix
        Returns:
        the column sums
      • colSumVector

        public static Vector colSumVector​(MatrixTable A)
        Get the column sum vector of a given matrix.
        Parameters:
        A - the matrix
        Returns:
        the column sum vector
      • rowMeans

        public static double[] rowMeans​(MatrixTable A)
        Get the row means. That is, the first element in the output array equals to the mean of the entries in the first row of the input matrix, so on and so forth. So, the number of entries in the output equals to the number of rows in the input matrix.
        Parameters:
        A - a matrix
        Returns:
        the row means
      • rowMeanVector

        public static Vector rowMeanVector​(MatrixTable A)
        Get the row mean vector of a given matrix.
        Parameters:
        A - the matrix
        Returns:
        the row mean vector
      • colMeans

        public static double[] colMeans​(MatrixTable A)
        Get the column means. That is, the first element in the output array equals to the mean of the entries in the first column of the input matrix, so on and so forth. So, the number of entries in the output equals to the number of columns in the input matrix.
        Parameters:
        A - a matrix
        Returns:
        the column means
      • colMeanVector

        public static Vector colMeanVector​(MatrixTable A)
        Get the column mean vector of a given matrix.
        Parameters:
        A - the matrix
        Returns:
        the column mean vector
      • deRowMean

        public static Matrix deRowMean​(Matrix A)
        Get the de-mean (row means) matrix of a given matrix.
        Parameters:
        A - the matrix
        Returns:
        the de-mean matrix
      • deColumnMean

        public static Matrix deColumnMean​(Matrix A)
        Get the de-mean (column means) matrix of a given matrix.
        Parameters:
        A - the matrix
        Returns:
        the de-mean matrix
      • to1DArray

        public static double[] to1DArray​(MatrixTable A)
        Get all matrix entries in the form of an 1D double[].
        Parameters:
        A - a matrix
        Returns:
        all matrix entries in double[]
      • to2DArray

        public static double[][] to2DArray​(MatrixTable A)
        Get all matrix entries in the form of a 2D double[][] array.
        Parameters:
        A - a matrix
        Returns:
        all matrix entries in double[][]
      • toRows

        public static Vector[] toRows​(Matrix A)
        Get an array of all row vectors from a matrix.
        Parameters:
        A - a matrix
        Returns:
        row vectors (indexed from top to bottom)
      • toColumns

        public static Vector[] toColumns​(Matrix A)
        Get an array of all column vectors from a matrix.
        Parameters:
        A - a matrix
        Returns:
        column vectors (indexed from left to right)
      • toString

        public static String toString​(MatrixTable A)
        Get the String representation of a matrix.
        Parameters:
        A - a matrix
        Returns:
        the String representation of a matrix