SSJ
V. labo.

umontreal.iro.lecuyer.util
Class DMatrix

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

public class DMatrix
extends Object

DMatrix

This class implements a few methods for matrix calculations with double numbers. Cette classe n'a pas été beaucoup testée. Doit-on enlever toutes les méthodes excepté les static?


Constructor Summary
DMatrix(DMatrix that)
          .
DMatrix(double[][] data, int r, int c)
          .
DMatrix(int r, int c)
          .
 
Method Summary
static void CholeskyDecompose(double[][] M, double[][] L)
          .
static DoubleMatrix2D CholeskyDecompose(DoubleMatrix2D M)
          [tabb54]
Mthe input matrix the Cholesky lower triangular matrix
static void copy(double[][] M, double[][] R)
          .
static double[][] exp(double[][] A)
          .
static DoubleMatrix2D exp(DoubleMatrix2D A)
          .
static DoubleMatrix2D expBidiagonal(DoubleMatrix2D A)
          .
static DoubleMatrix1D expBidiagonal(DoubleMatrix2D A, DoubleMatrix1D b)
          .
static DoubleMatrix2D expmiBidiagonal(DoubleMatrix2D A)
          .
static DoubleMatrix1D expmiBidiagonal(DoubleMatrix2D A, DoubleMatrix1D b)
          .
 double get(int row, int column)
          .
 int numColumns()
          .
 int numRows()
          .
static void PCADecompose(double[][] M, double[][] A, double[] lambda)
          .
static DoubleMatrix2D PCADecompose(DoubleMatrix2D M, double[] lambda)
          .
 void set(int row, int column, double value)
          .
static double[] solveLU(double[][] A, double[] b)
          .
static void solveTriangular(DoubleMatrix2D U, DoubleMatrix2D B, DoubleMatrix2D X)
          .
 String toString()
          .
static String toString(double[][] M)
          .
 DMatrix transpose()
          .
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DMatrix

public DMatrix(int r,
               int c)
. \begin{tabb}Creates a new \texttt{DMatrix} with \texttt{r} rows and
 \texttt{c} columns.
 \end{tabb}
rthe number of rows cthe number of columns


DMatrix

public DMatrix(double[][] data,
               int r,
               int c)
. \begin{tabb}Creates a new \texttt{DMatrix} with \texttt{r} rows and
 \texttt{c} columns using the data in \texttt{data}.
 \end{tabb}
datathe data of the new DMatrix rthe number of rows cthe number of columns


DMatrix

public DMatrix(DMatrix that)
. \begin{tabb}Copy constructor.
 \end{tabb}
thatthe DMatrix to copy

Method Detail

CholeskyDecompose

public static void CholeskyDecompose(double[][] M,
                                     double[][] L)
. \begin{tabb}Given a symmetric positive-definite matrix $M$, performs the
 Cholesk...
 ...s the result as a lower triangular
 matrix $L$, such that $M = L L^T$.
 \end{tabb}
Mthe input matrix Lthe Cholesky lower triangular matrix


CholeskyDecompose

public static DoubleMatrix2D CholeskyDecompose(DoubleMatrix2D M)
[tabb54]
Mthe input matrix the Cholesky lower triangular matrix


PCADecompose

public static void PCADecompose(double[][] M,
                                double[][] A,
                                double[] lambda)
. \begin{tabb}Computes the principal components decomposition $M$\ =
 $U\Lambda U^...
 ...exttt{lambda}, and puts matrix
 $A = U\sqrt{\Lambda}$\ in \texttt{A}.
 \end{tabb}
Minput matrix Amatrix square root of M lambdathe eigenvalues


PCADecompose

public static DoubleMatrix2D PCADecompose(DoubleMatrix2D M,
                                          double[] lambda)
. \begin{tabb}Computes the principal components decomposition $M$\ =
 $U\Lambda U^...
 ...ze, in vector \texttt{lambda}. Returns matrix
 $A = U\sqrt{\Lambda}$.
 \end{tabb}
Minput matrix lambdathe eigenvalues matrix square root of M


solveLU

public static double[] solveLU(double[][] A,
                               double[] b)
. \begin{tabb}Solves the matrix equation $Ax = b$\ using LU decomposition.
 $A$\ is a square matrix, $b$\ and $x$\ are vectors. Returns the solution $x$.
 \end{tabb}
Asquare matrix bright side vector the solution vector


solveTriangular

public static void solveTriangular(DoubleMatrix2D U,
                                   DoubleMatrix2D B,
                                   DoubleMatrix2D X)
. \begin{tabb}Solve the triangular matrix equation $UX = B$\ for $X$.
 $U$\ is a s...
 ...riangular matrix. $B$\ and $X$\ must have the same
 number of columns.
 \end{tabb}
Uinput matrix Bright-hand side matrix Xoutput matrix


exp

public static double[][] exp(double[][] A)
. \begin{tabb}Similar to \method{exp}{(DoubleMatrix2D)}\texttt{(A)}.
 \end{tabb}
Ainput matrix the exponential of A


exp

public static DoubleMatrix2D exp(DoubleMatrix2D A)
. \begin{tabb}Returns $e^A$, the exponential of the square matrix $A$.
 The scaling...
 ...mHIG09a} is used with
 Pad\'e approximants to compute the exponential.
 \end{tabb}
Ainput matrix the exponential of A


expBidiagonal

public static DoubleMatrix2D expBidiagonal(DoubleMatrix2D A)
. \begin{tabb}Returns $e^A$, the exponential of the \emph{bidiagonal}
 square matr...
 ...xp}{(DoubleMatrix2D)}\texttt{(A)} because of the special form of $A$.
 \end{tabb}
Abidiagonal matrix eA


expBidiagonal

public static DoubleMatrix1D expBidiagonal(DoubleMatrix2D A,
                                           DoubleMatrix1D b)
. \begin{tabb}Computes $c = e^A b$, where $e^A$\ is the exponential of the \emph{b...
 ... squaring method\cite{mHIG09a} with
 Pad\'e approximants. Returns $c$.
 \end{tabb}
Abidiagonal matrix eA


expmiBidiagonal

public static DoubleMatrix2D expmiBidiagonal(DoubleMatrix2D A)
. \begin{tabb}Computes $e^A - I$, where $e^A$\ is the exponential of the \emph{bid...
 ...od\cite{mSKA09a,mHIG09a} with
 Pad\'e approximants. Returns $e^A - I$.
 \end{tabb}
Abidiagonal matrix (eA - I)b


expmiBidiagonal

public static DoubleMatrix1D expmiBidiagonal(DoubleMatrix2D A,
                                             DoubleMatrix1D b)
. \begin{tabb}Computes $c = (e^A - I)b$, where $e^A$\ is the exponential of the
 \...
 ...ng method\cite{mSKA09a,mHIG09a} with a Taylor expansion. Returns $c$.
 \end{tabb}
Abidiagonal matrix bvector c


\begin{hide}
 \par
 \end{hide}


copy

public static void copy(double[][] M,
                        double[][] R)
. \begin{tabb}Copies the matrix $M$\ into $R$.
 \end{tabb}
Moriginal matrix Routput matrix


toString

public static String toString(double[][] M)
. \begin{tabb}Returns matrix $M$\ as a string.
 It is displayed in matrix form, with each row on a line.
 \end{tabb}
the content of M


toString

public String toString()
. \begin{tabb}Creates a \class{String} containing all the data of
 the \texttt{DMatrix}. The result is displayed in matrix form, with
 each row on a line.
 \end{tabb}
the content of the DMatrix

Overrides:
toString in class Object

numRows

public int numRows()
. \begin{tabb}Returns the number of rows of the \texttt{DMatrix}.
 \end{tabb}
the number of rows


numColumns

public int numColumns()
. \begin{tabb}Returns the number of columns of the \texttt{DMatrix}.
 \end{tabb}
the number of columns


get

public double get(int row,
                  int column)
. \begin{tabb}Returns the matrix element in the specified row and column.
 \end{tabb}
rowthe row of the selected element columnthe column of the selected element the value of the element IndexOutOfBoundsExceptionif the selected element would be outside the DMatrix


set

public void set(int row,
                int column,
                double value)
. \begin{tabb}Sets the value of the element in the specified row and column.
 \end{tabb}
rowthe row of the selected element columnthe column of the selected element valuethe new value of the element IndexOutOfBoundsExceptionif the selected element would be outside the DMatrix


transpose

public DMatrix transpose()
. \begin{tabb}Returns the transposed matrix. The rows and columns are
 interchanged.
 \end{tabb}
the transposed matrix


SSJ
V. labo.

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