Class Rmxn
- All Implemented Interfaces:
IArchive
- Since:
- Jul 21, 2015
- Author:
- Christopher K. Allen
-
Field Summary
Fields inherited from class xal.tools.math.BaseMatrix
ATTR_DATA, DBL_EPS, ULPS_BRACKET
-
Constructor Summary
ConstructorsConstructorDescriptionRmxn
(double[][] arrVals) Initializing constructor for classRmxn
.Rmxn
(int cntRows, int cntCols) Zero-matrix constructor for classRmxn
.Parsing Constructor - creates an instance of the child class and initialize it according to a token string of element values.Copy constructor forRmxn
. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Base classes must override the clone operation in order to make deep copies of the current object.Non-destructive matrix subtraction.void
minusEquals
(Rmxn matSub) In-place matrix subtraction.static Rmxn
newIdentity
(int cntSize) Creates and returns a new instance of the identity matrix with the given dimensions.protected Rmxn
newInstance
(int row, int col) Returns a new, zero element, instance ofRmxn
which has the same dimensions as this object.Non-destructive matrix addition.void
plusEquals
(Rmxn matAddend) In-place matrix addition.Non-destructive matrix-vector multiplication.Methods inherited from class xal.tools.math.BaseMatrix
assignIdentity, assignMatrix, assignZero, conditionNumber, copy, equals, getArrayCopy, getColCnt, getElem, getElem, getMatrix, getRowCnt, hashCode, inverse, isApproxEqual, isApproxEqual, isEquivalentTo, isSquare, load, max, newInstance, norm1, norm2, normF, normInf, print, rank, save, setElem, setElem, setMatrix, setMatrix, setSubMatrix, times, times, times, timesEquals, toString, toStringMatrix, toStringMatrix, toStringMatrix, transpose
-
Constructor Details
-
Rmxn
public Rmxn(int cntRows, int cntCols) Zero-matrix constructor for classRmxn
. A matrix of the given dimension is created, all the elements are zero.- Parameters:
cntRows
- number of matrix rowscntCols
- number of matrix columns- Since:
- Jul 21, 2015 by Christopher K. Allen
-
Rmxn
Initializing constructor for class
Rmxn
. Initializes the matrix to the values given in the Java primitive type double array by setting the internal matrix representation to the given Java array. The matrix is shaped according to the (row-packed) argument.The dimensions of the given Java double array determine the size of the matrix. An mxn Java double array creates an mxn
Rmxn
array. If the argument is not fully allocated or inconsistent, an exception is thrown.As an example consider the following Java array
double[][] arrInternal = new double[][] { {1.1, 1.2, 1.3, 1.4, 1.5}, {2.1, 2.2, 2.3, 2.0, 2.5}, {3.1, 3.2, 3.3, 3.4, 3.0} };
arrInternal
will be changed by the the encapsulating matrix object so should no longer be referenced after presenting it to this constructor.- Parameters:
arrVals
- Java primitive array to be new internal matrix value representation- Throws:
IllegalArgumentException
- the argument is degenerate and cannot represent a matrixArrayIndexOutOfBoundsException
- Since:
- Jul 21, 2015 by Christopher K. Allen
-
Rmxn
public Rmxn(int cntRows, int cntCols, String strTokens) throws IllegalArgumentException, NumberFormatException Parsing Constructor - creates an instance of the child class and initialize it according to a token string of element values.
The token string argument is assumed to be one-dimensional and packed by column (ala FORTRAN).
- Parameters:
cntRows
- the matrix row size of this objectcntCols
- the matrix column size of this objectstrTokens
- token vector of getSize()^2 numeric values- Throws:
IllegalArgumentException
- wrong number of token stringsNumberFormatException
- bad number format, unparseable- Since:
- Jul 21, 2015 by Christopher K. Allen
-
Rmxn
Copy constructor forRmxn
. A new instance is created which is a deep copy of the given argument.- Parameters:
matTemplate
- matrix to be cloned- Since:
- Jul 21, 2015 by Christopher K. Allen
-
-
Method Details
-
newIdentity
Creates and returns a new instance of the identity matrix with the given dimensions.- Parameters:
cntSize
- the size of the identity matrix (i.e., row and column count)- Returns:
- Since:
- Jul 23, 2015 by Christopher K. Allen
-
plus
Description copied from class:BaseMatrix
Non-destructive matrix addition. This matrix is unaffected.- Overrides:
plus
in classBaseMatrix<Rmxn>
- Parameters:
matAddend
- matrix to be added to this- Returns:
- the result of this matrix plus the given matrix (element-wise),
or
null
if error - Throws:
IllegalArgumentException
- Inconsistent matrix dimensions- Since:
- Jul 22, 2015 by Christopher K. Allen
- See Also:
-
plusEquals
Description copied from class:BaseMatrix
In-place matrix addition. The given matrix is added to this matrix algebraically (element by element).- Overrides:
plusEquals
in classBaseMatrix<Rmxn>
- Parameters:
matAddend
- matrix to be added to this (no new objects are created)- Throws:
IllegalArgumentException
- Inconsistent matrix dimensions- Since:
- Jul 22, 2015 by Christopher K. Allen
- See Also:
-
minus
Description copied from class:BaseMatrix
Non-destructive matrix subtraction. This matrix is unaffected.- Overrides:
minus
in classBaseMatrix<Rmxn>
- Parameters:
matSub
- the subtrahend- Returns:
- the value of this matrix minus the value of the given matrix, or
null
if an error occurred - Throws:
IllegalArgumentException
- Inconsistent matrix dimensions- Since:
- Jul 22, 2015 by Christopher K. Allen
- See Also:
-
minusEquals
Description copied from class:BaseMatrix
In-place matrix subtraction. The given matrix is subtracted from the value of this matrix. No additional objects are created.- Overrides:
minusEquals
in classBaseMatrix<Rmxn>
- Parameters:
matSub
- subtrahend- Throws:
IllegalArgumentException
- Inconsistent matrix dimensions- Since:
- Jul 22, 2015 by Christopher K. Allen
- See Also:
-
times
Non-destructive matrix-vector multiplication. The returned value is the usual product of the given vector pre-multiplied by this matrix. Specifically, denote by A this matrix and by x the argument vector, then the components {yi} of the returned vector y are given by
yi = Σj Aijxj
The returned vector must be created using Java reflection, so this operation is somewhat more risky and expensive than and in place multiplication.
- Parameters:
vecFac
- the vector factor- Returns:
- the matrix-vector product of this matrix with the argument
- Throws:
IllegalArgumentException
- the argument vector must have compatible dimensions- Since:
- Oct 11, 2013
-
clone
Description copied from class:BaseMatrix
Base classes must override the clone operation in order to make deep copies of the current object. This operation cannot be done without the exact type.- Specified by:
clone
in classBaseMatrix<Rmxn>
- Since:
- Jul 21, 2015 by Christopher K. Allen
- See Also:
-
newInstance
Returns a new, zero element, instance ofRmxn
which has the same dimensions as this object. That is, the returned object is in the same equivalence class of matrices as this one.- Specified by:
newInstance
in classBaseMatrix<Rmxn>
- Parameters:
row
- Number of rows.col
- Number of columns.- Returns:
- uninitialized matrix object of type
M
- Since:
- Jul 21, 2015 by Christopher K. Allen
- See Also:
-
xal.tools.math.BaseMatrix#newInstance()
-