p3j.misc.math
Class Matrix2D

java.lang.Object
  extended by cern.colt.PersistentObject
      extended by cern.colt.matrix.impl.AbstractMatrix
          extended by cern.colt.matrix.impl.AbstractMatrix2D
              extended by cern.colt.matrix.DoubleMatrix2D
                  extended by cern.colt.matrix.impl.DenseDoubleMatrix2D
                      extended by p3j.misc.math.Matrix2D
All Implemented Interfaces:
Serializable, Cloneable

public class Matrix2D
extends cern.colt.matrix.impl.DenseDoubleMatrix2D

Wrapper class for matrices. Created on July 04, 2006

Author:
Christina Bohk, Roland Ewald
See Also:
Serialized Form

Field Summary
 
Fields inherited from class cern.colt.matrix.impl.DenseDoubleMatrix2D
elements
 
Fields inherited from class cern.colt.matrix.impl.AbstractMatrix2D
columns, columnStride, columnZero, rows, rowStride, rowZero
 
Fields inherited from class cern.colt.matrix.impl.AbstractMatrix
isNoView
 
Constructor Summary
Matrix2D()
          Constructor for bean compatibility.
Matrix2D(double[][] values, String rLabel, String cLabel)
          Standard constructor.
Matrix2D(int rows, int columns)
          Alternative constructor.
 
Method Summary
static Matrix2D add(List<Matrix2D> addList)
          Adds a number of given matrices.
 void assignColumn(int index, double[] values)
          Assigns column values.
 void assignColumn(int indexSourceColumn, Matrix2D source, int indexTargetColumn)
          Copies content from source column of source matrix to target column of this matrix.
static long calculateHashCode(Matrix2D val)
          Calculates hash code of the value Matrix2D.
 Matrix2D copy()
           
 boolean equals(Object o)
           
 String getColumnLabel()
           
 Matrix2D getResizedMatrix(int newRows, int newCols)
          Create a matrix with differing dimensions.
 String getRowLabel()
           
 int hashCode()
           
 void setColumnLabel(String columnLabel)
           
 void setRowLabel(String rowLabel)
           
 Matrix2D sub(List<Matrix2D> subList)
          Subtract list of matrices, element-wise.
static void subMatrix(Matrix2D source, Matrix2D target)
          Copies as much as possible from the source to the target.
static Matrix2D sumRows(Matrix2D mat)
          Sums up all rows of a matrix column-wise.
static Matrix2D sumRows(Matrix2D mat, Integer lowerBorder, Integer upperBorder)
          Sums up some rows of a matrix column-wise.
 
Methods inherited from class cern.colt.matrix.impl.DenseDoubleMatrix2D
assign, assign, assign, assign, assign, getQuick, haveSharedCellsRaw, index, like, like1D, like1D, setQuick, viewSelectionLike, zAssign8Neighbors, zMult, zMult, zSum
 
Methods inherited from class cern.colt.matrix.DoubleMatrix2D
aggregate, aggregate, cardinality, equals, forEachNonZero, get, getContent, getNonZeros, haveSharedCells, like, set, toArray, toString, view, viewColumn, viewColumnFlip, viewDice, viewPart, viewRow, viewRowFlip, viewSelection, viewSelection, viewSorted, viewStrides, zMult, zMult
 
Methods inherited from class cern.colt.matrix.impl.AbstractMatrix2D
_columnOffset, _columnRank, _rowOffset, _rowRank, checkBox, checkColumn, checkColumnIndexes, checkRow, checkRowIndexes, checkShape, checkShape, columns, rows, setUp, setUp, size, toStringShort, vColumnFlip, vDice, vPart, vRowFlip, vStrides
 
Methods inherited from class cern.colt.matrix.impl.AbstractMatrix
ensureCapacity, isView, trimToSize
 
Methods inherited from class cern.colt.PersistentObject
clone
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Matrix2D

public Matrix2D(double[][] values,
                String rLabel,
                String cLabel)
Standard constructor.

Parameters:
values - matrix values
rLabel - the row label
cLabel - the column label

Matrix2D

public Matrix2D()
Constructor for bean compatibility.


Matrix2D

public Matrix2D(int rows,
                int columns)
Alternative constructor.

Parameters:
rows - number of rows
columns - number of columns
Method Detail

assignColumn

public void assignColumn(int index,
                         double[] values)
Assigns column values.

Parameters:
index - index of the column to be filled
values - values to be filled in

assignColumn

public void assignColumn(int indexSourceColumn,
                         Matrix2D source,
                         int indexTargetColumn)
Copies content from source column of source matrix to target column of this matrix.

Parameters:
indexSourceColumn - index of the column in the source matrix
source - the source matrix
indexTargetColumn - index of the column in the target matrix

copy

public Matrix2D copy()
Overrides:
copy in class cern.colt.matrix.DoubleMatrix2D

calculateHashCode

public static long calculateHashCode(Matrix2D val)
Calculates hash code of the value Matrix2D.

Parameters:
val - the matrix for which the hash code shall be computed
Returns:
the hash code of the matrix

equals

public boolean equals(Object o)
Overrides:
equals in class cern.colt.matrix.DoubleMatrix2D

hashCode

public int hashCode()
Overrides:
hashCode in class Object

subMatrix

public static void subMatrix(Matrix2D source,
                             Matrix2D target)
Copies as much as possible from the source to the target.

Parameters:
source - the source matrix
target - the target matrix

getColumnLabel

public String getColumnLabel()

setColumnLabel

public void setColumnLabel(String columnLabel)

getRowLabel

public String getRowLabel()

setRowLabel

public void setRowLabel(String rowLabel)

add

public static Matrix2D add(List<Matrix2D> addList)
Adds a number of given matrices. All have to have the same dimensions

Parameters:
addList - the list of given matrices m_1, ..., m_n
Returns:
resulting matrix m_1 + ... + m_n

sumRows

public static Matrix2D sumRows(Matrix2D mat)
Sums up all rows of a matrix column-wise.

Parameters:
mat - the matrix whose columns should be summed up
Returns:
result matrix 1 x columns

sumRows

public static Matrix2D sumRows(Matrix2D mat,
                               Integer lowerBorder,
                               Integer upperBorder)
Sums up some rows of a matrix column-wise. Set null to lower/upper border to set it to default value (0/rows(), respectively).

Parameters:
mat - the matrix whose columns should be summed up
lowerBorder - the lower border
upperBorder - the upper border
Returns:
result matrix 1 x columns

sub

public Matrix2D sub(List<Matrix2D> subList)
Subtract list of matrices, element-wise.

Parameters:
subList - the list of matrices to be subtracted
Returns:
the result matrix

getResizedMatrix

public Matrix2D getResizedMatrix(int newRows,
                                 int newCols)
Create a matrix with differing dimensions. Unknown values are filled with zeros.

Parameters:
newRows - the new number of rows
newCols - the new number of columns
Returns:
a new matrix of the appropriate sizes


Copyright © 2012. All Rights Reserved.