Overview | Package | Class | Tree | Deprecated | Index | Help
| SSJ V. 2.1.1.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## umontreal.iro.lecuyer.util
Class DMatrix

    java.lang.Object
      umontreal.iro.lecuyer.util.DMatrix

    public class DMatrix

extends Object

This class implements a few methods for matrix calculations with `double` numbers.

Constructor Summary
`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
`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.
`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.
`double` | `get(int row, int column)` Returns the matrix element in the specified row and column.
`int` | `numColumns()` Returns the number of columns of the `DMatrix`.
`int` | `numRows()` Returns the number of rows of the `DMatrix`.
`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.
`static DoubleMatrix2D` | `PCADecompose(DoubleMatrix2D M, double[] lambda)` Computes the principal components decomposition M = UΛUt by using the singular value decomposition of matrix M.
`void` | `set(int row, int column, double value)` Sets the value of the element in the specified row and column.
`String` | `toString()` Creates a `String` containing all the data of the `DMatrix`.
`static String` | `toString(double[][] M)` Returns matrix M as a string.
`DMatrix` | `transpose()` Returns the transposed matrix.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

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

Overview | Package | Class | Tree | Deprecated | Index | Help
| SSJ V. 2.1.1.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

To submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.