DMatrix
umontreal.iro.lecuyer.util

Class DMatrix



  • public class DMatrixextends Object
    This class implements a few methods for matrix calculations with double numbers.
    • Constructor Summary

      Constructors 
      Constructor and Description
      DMatrix(DMatrix that)
      Copy constructor.
      DMatrix(double[][] data, int r, int c)
      Creates a new DMatrix with r rows and c columns using the data in data.
      DMatrix(int r, int c)
      Creates a new DMatrix with r rows and c columns.
    • Method Summary

      Methods 
      Modifier and TypeMethod and Description
      static voidCholeskyDecompose(double[][] M, double[][] L)
      Given a symmetric positive-definite matrix M, performs the Cholesky decomposition of M and returns the result as a lower triangular matrix L, such that M = LLT.
      static DoubleMatrix2DCholeskyDecompose(DoubleMatrix2D M)
      Given a symmetric positive-definite matrix M, performs the Cholesky decomposition of M and returns the result as a lower triangular matrix L, such that M = LLT.
      doubleget(int row, int column)
      Returns the matrix element in the specified row and column.
      intnumColumns()
      Returns the number of columns of the DMatrix.
      intnumRows()
      Returns the number of rows of the DMatrix.
      static voidPCADecompose(double[][] M, double[][] A, double[] lambda)
      Computes the principal components decomposition M = UΛUt by using the singular value decomposition of matrix M.
      static DoubleMatrix2DPCADecompose(DoubleMatrix2D M, double[] lambda)
      Computes the principal components decomposition M = UΛUt by using the singular value decomposition of matrix M.
      voidset(int row, int column, double value)
      Sets the value of the element in the specified row and column.
      StringtoString()
      Creates a String containing all the data of the DMatrix.
      static StringtoString(double[][] M)
      Returns matrix M as a string.
      DMatrixtranspose()
      Returns the transposed matrix.
    • Constructor Detail

      • DMatrix

        public DMatrix(int r,       int c)
        Creates a new DMatrix with r rows and c columns.
        Parameters:
        r - the number of rows
        c - the number of columns
      • DMatrix

        public DMatrix(double[][] data,       int r,       int c)
        Creates a new DMatrix with r rows and c columns using the data in data.
        Parameters:
        data - the data of the new DMatrix
        r - the number of rows
        c - the number of columns
      • DMatrix

        public DMatrix(DMatrix that)
        Copy constructor.
        Parameters:
        that - the DMatrix to copy
    • Method Detail

      • CholeskyDecompose

        public static void CholeskyDecompose(double[][] M,                     double[][] L)
        Given a symmetric positive-definite matrix M, performs the Cholesky decomposition of M and returns the result as a lower triangular matrix L, such that M = LLT.
        Parameters:
        M - the input matrix
        L - the Cholesky lower triangular matrix
      • CholeskyDecompose

        public static DoubleMatrix2D CholeskyDecompose(DoubleMatrix2D M)
        Given a symmetric positive-definite matrix M, performs the Cholesky decomposition of M and returns the result as a lower triangular matrix L, such that M = LLT.
        Parameters:
        M - the input matrix
        Returns:
        the Cholesky lower triangular matrix
      • PCADecompose

        public static void PCADecompose(double[][] M,                double[][] A,                double[] lambda)
        Computes the principal components decomposition M = UΛUt by using the singular value decomposition of matrix M. Puts the eigenvalues, which are the diagonal elements of matrix Λ, sorted by decreasing size, in vector lambda, and puts matrix A = U(Λ)1/2 in A.
        Parameters:
        M - input matrix
        A - matrix square root of M
        lambda - the eigenvalues
      • PCADecompose

        public static DoubleMatrix2D PCADecompose(DoubleMatrix2D M,                          double[] lambda)
        Computes the principal components decomposition M = UΛUt by using the singular value decomposition of matrix M. Puts the eigenvalues, which are the diagonal elements of matrix Λ, sorted by decreasing size, in vector lambda. Returns matrix A = U(Λ)1/2.
        Parameters:
        M - input matrix
        lambda - the eigenvalues
        Returns:
        matrix square root of M
      • toString

        public static String toString(double[][] M)
        Returns matrix M as a string. It is displayed in matrix form, with each row on a line.
        Returns:
        the content of M
      • toString

        public String toString()
        Creates a String containing all the data of the DMatrix. The result is displayed in matrix form, with each row on a line.
        Overrides:
        toString in class Object
        Returns:
        the content of the DMatrix
      • numRows

        public int numRows()
        Returns the number of rows of the DMatrix.
        Returns:
        the number of rows
      • numColumns

        public int numColumns()
        Returns the number of columns of the DMatrix.
        Returns:
        the number of columns
      • get

        public double get(int row,         int column)
        Returns the matrix element in the specified row and column.
        Parameters:
        row - the row of the selected element
        column - the column of the selected element
        Returns:
        the value of the element
        Throws:
        IndexOutOfBoundsException - if the selected element would be outside the DMatrix
      • set

        public void set(int row,       int column,       double value)
        Sets the value of the element in the specified row and column.
        Parameters:
        row - the row of the selected element
        column - the column of the selected element
        value - the new value of the element
        Throws:
        IndexOutOfBoundsException - if the selected element would be outside the DMatrix
      • transpose

        public DMatrix transpose()
        Returns the transposed matrix. The rows and columns are interchanged.
        Returns:
        the transposed matrix

SCaVis 1.7 © jWork.org