ContactCenters
V. 0.9.9.

umontreal.iro.lecuyer.contactcenters
Class MatrixUtil

java.lang.Object
  extended by umontreal.iro.lecuyer.contactcenters.MatrixUtil

public class MatrixUtil
extends Object

Contains utility methods to add rows or columns to matrices, and to construct a matrix by repeating a submatrix several times.


Method Summary
static DoubleMatrix2D addSumColumn(DoubleMatrix2D m)
          Equivalent to addSumColumn (m, false).
static DoubleMatrix2D addSumColumn(DoubleMatrix2D m, boolean always)
          This method, similar to addSumRow(DoubleMatrix2D,boolean), adds an extra column to the matrix m for the sum of each column.
static DoubleMatrix2D addSumRow(DoubleMatrix2D m)
          Equivalent to addSumRow (m, false).
static DoubleMatrix2D addSumRow(DoubleMatrix2D m, boolean always)
          Makes a copy of the matrix m with a new row containing the sum of each column.
static DoubleMatrix2D getCost(DoubleMatrix2D m, double[] cost)
          Converts the matrix m into a matrix of costs using the cost vector cost.
static DoubleMatrix2D repMat(DoubleMatrix2D m, int numRows, int numCols)
          Constructs a matrix by copying m a certain number of times.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getCost

public static DoubleMatrix2D getCost(DoubleMatrix2D m,
                                     double[] cost)
Converts the matrix m into a matrix of costs using the cost vector cost. The matrix m should contain counts of events, e.g., the number of arrivals, or the integral over simulation time of a quantity, e.g., the queue size. Each row corresponds to one count and each column represents one period. Assuming the cost vector is a row vector in $ \RR^{d}_{}$, the method computes C*M, and stores the result in the matrix m. C is a d×d matrix with the costs on its diagonal, i.e., Ck, k = costs[k], and Ci, j = 0 for ij. M is a d×P matrix stored in m. If m has d + 1 rows, the last row of the matrix is filled with the total costs, i.e.,

Md, j = $\displaystyle \htsum_{{i=0}}^{{d-1}}$Mi, jCi, i

for j = 0,…, P - 1.

Parameters:
m - the matrix of values.
cost - the cost vector.
Returns:
the given matrix m.
Throws:
IllegalArgumentException - if the length of cost does not correspond to m.rows() or m.rows() - 1.

addSumRow

public static DoubleMatrix2D addSumRow(DoubleMatrix2D m)
Equivalent to addSumRow (m, false).

Parameters:
m - the matrix being processed.
Returns:
the matrix with the added row of sums.

addSumRow

public static DoubleMatrix2D addSumRow(DoubleMatrix2D m,
                                       boolean always)
Makes a copy of the matrix m with a new row containing the sum of each column. If m has a single row and if always is set to false, the matrix is returned unchanged. Otherwise, a new matrix is created with the additional row of sums. The sums of columns are stored in the last row of the returned matrix.

Parameters:
m - the matrix being processed.
always - if true, the row is added even if m has one row.
Returns:
the matrix with the added row of sums.

addSumColumn

public static DoubleMatrix2D addSumColumn(DoubleMatrix2D m)
Equivalent to addSumColumn (m, false).

Parameters:
m - the matrix being processed.
Returns:
the matrix with the added column of sums.

addSumColumn

public static DoubleMatrix2D addSumColumn(DoubleMatrix2D m,
                                          boolean always)
This method, similar to addSumRow(DoubleMatrix2D,boolean), adds an extra column to the matrix m for the sum of each column.

Parameters:
m - the matrix being processed.
always - determines if the column is always added.
Returns:
the matrix with the added column of sums.

repMat

public static DoubleMatrix2D repMat(DoubleMatrix2D m,
                                    int numRows,
                                    int numCols)
Constructs a matrix by copying m a certain number of times. The new matrix contains numRows*numCols copies of m tiled in a grid with dimensions numRows×numCols. If numRows and numCols are both 1, the matrix is returned unchanged.

Parameters:
m - the matrix to be tiled.
numRows - the number of rows containing copies of m.
numCols - the number of columns containing copies of m.
Returns:
the matrix containing copies of m.

ContactCenters
V. 0.9.9.

To submit a bug or ask questions, send an e-mail to Richard Simard.