public class NumberMatrix extends Matrix implements NumberTypeDependentIF, ExerciseCompoundObjectIF
UNEDITED_NODE_NAME
Constructor and Description |
---|
NumberMatrix(java.lang.Class numberClass,
boolean rowWise,
NumberTuple[] rowcol)
Constructs a number matrix of number type
numberClass and with
the NumberTuple -array treated as rows or columns for this
NumberMatrix in dependence of rowWise . |
NumberMatrix(java.lang.Class numberClass,
int dimension)
constructs a zero square matrix with entries of number type
numberClass and of desired dimension. |
NumberMatrix(java.lang.Class numberClass,
int numOfCols,
int numOfRows)
constructs a zero matrix with entries of number type
numberClass and with numOfCols columns and
numOfRows rows. |
NumberMatrix(java.lang.Class numberClass,
int numOfCols,
java.lang.Object[] entries)
constructs a
NumberMatrix with numOfCols number
of columns and with the number entries of type numberClass . |
NumberMatrix(int numOfCols,
int numOfRows,
double[] values)
For convenience: Produces a mxn double matrix with the given (row-wise) entries as values.
|
NumberMatrix(org.w3c.dom.Node content)
Constructs a new instance with the given MathML/XML content.
|
NumberMatrix(NumberMatrix matrix)
constructs a
NumberMatrix that is a deep copy of
matrix . |
NumberMatrix(NumberTuple[] domain,
NumberTuple[] range)
constructs an instance of
NumberMatrix M that complies
to M∗domain[i] = range[i] (where ∗ means the standard
matrix multiplication and domain[i] is treated as columnvector. |
Modifier and Type | Method and Description |
---|---|
NumberMatrix |
addTo(NumberMatrix aMatrix)
Adds
aMatrix to this matrix and returns this . |
NumberMatrix |
adjoint()
This method return the adjoint of this matrix.
|
NumberTuple |
applyTo(NumberTuple aColumnTupel)
Method applyTo applies a matrix to a column vector by standard matrix
multiplication.
|
void |
applyTo(NumberTuple aColumnTupel,
NumberTuple result)
Up to 4 times faster than the method above.
|
protected void |
checkEntry(java.lang.Object entry)
Should check validity of a matrix entry m_ij.
|
NumberMatrix |
copyFrom(NumberMatrix aMatrix)
All
MNumber entries in this matrix
will be set to the value of the corresponding entry in aMatrix . |
NumberMatrix |
copyFrom(NumberMatrix aMatrix,
boolean copyEditedFlags)
All
MNumber entries in this matrix
will be set to the value of the corresponding entry in aMatrix . |
NumberMatrix |
deepCopy()
This method returns a new instance of
NumberMatrix which has
the same dimension as this matrix and identical entries, i.e. |
MNumber |
determinant()
Computes the determinant of this matrix if it is square and throws an
IllegalUsageException otherwise. |
MNumber |
distance(NumberMatrix aMatrix)
Returns the distance between this and
aMatrix . |
static MNumber |
distance(NumberMatrix matrix1,
NumberMatrix matrix2)
Returns the distance between 2 matrices.
|
NumberMatrix |
echelonForm() |
boolean |
equals(java.lang.Object shouldBeAMatrix) |
int |
equalsWithErrorCounter(java.lang.Object shouldBeAMatrix)
compares this matrix with another one and returns the number
of different matrix entries
returns Integer.MAX_VALUE if both matrices differ in shape
or 'shouldBeAMatrix' isn't an instance of NumberMatrix
|
void |
exportColumn(int col,
NumberTuple colTupel) |
void |
exportRow(int row,
NumberTuple rowTupel) |
void |
exportToColumns(NumberTuple[] columnTupel)
Fills up the given
columnTupel with the corresponding entries
in this matrix, i.e. |
void |
exportToRows(NumberTuple[] rowTupel)
Fills up the given
columnTupel with the corresponding entries
in this matrix, i.e. |
Polynomial |
getCharPoly() |
NumberTuple |
getColumnVector(int columnNumber) |
NumberTuple[] |
getColumnVectors() |
MNumber[] |
getEntriesAsNumberRef()
Returns all entries of this
NumberMatrix rowwise as a one
dimensional array of MNumber s. |
MNumber |
getEntry(int row,
int col)
Returns a copy of the entry for the given indices.
|
MNumber |
getEntryAsNumberRef(int row,
int column)
|
static NumberMatrix |
getIdentity(java.lang.Class entryClass,
int dimension) |
java.lang.String |
getLabel()
Returns the label for this exercise object.
|
MNumber |
getMaxAbsEntryRef() |
java.lang.Class |
getNumberClass()
Returns the class object of the underlying number type of this geometric
object.
|
NumberTuple |
getRowVector(int rowNumber) |
NumberTuple[] |
getRowVectors() |
boolean |
getUsedVariables() |
boolean |
getUsedVariables(int row,
int col)
Returns if the cell at the specified position was edited.
|
protected void |
init(int numOfCols,
java.lang.Object[] entries)
initializes the matrix with numOfCols und entries.
|
NumberMatrix |
inverse()
This instance of
NumberMatrix will become the (mathematical)
inverse of itsself. |
NumberMatrix |
inverted()
Returns the inverse this matrix and throws an
IllegalUsageException
if it is not possible. |
boolean |
isCollinear(NumberMatrix aMatrix)
this method tests if this
NumberMatrix is collinear to
aMatrix , i.e. if it is a multiple of it. |
boolean |
isCompletelyEdited()
Returns true if all entries were edited by the user.
|
boolean |
isDiagonalMatrix()
checks whether the non zero entries of this matrix only appear on the
(virtual) diagonal.
|
boolean |
isEdited()
Returns true if at least one entry was edited by the user.
|
boolean |
isEdited(int row,
int col)
Returns if the cell at the specified position was edited.
|
boolean |
isHidden()
Returns whether this exercise object should be hidden or not.
|
boolean |
isIdentity()
Tests whether this matrix is the identity or not.
|
boolean |
isInvertible()
Checks whether this matrix is invertible or not.
|
boolean |
isNormalForm() |
boolean |
isNormalForm(int row,
int col)
Returns if the cell at the specified position was edited.
|
boolean |
isOrthogonal()
Checks whether this matrix is orthogonal, i.e. if M^-1 = M^T.
|
boolean |
isProjector()
checks whether this matrix is idempotent or not, i.e. whether
M*M = M.
|
boolean |
isRealType() |
boolean |
isReflection() |
boolean |
isRotation()
Checks whether this matrix represents a rotation, i.e. if it is orthogonal
and its determinant equals 1.
|
boolean |
isZero()
Returns true if all entries are equal to zero.
|
NumberMatrix |
mult(NumberMatrix aMatrix)
This methods performs the matrix multiplication between this
NumberMatrix and aMatrix and changes this instance, i.e. |
static NumberMatrix |
mult(NumberMatrix m1,
NumberMatrix m2)
Returns a new matrix with the values of m1.mult(m2).
|
NumberMatrix |
multWithNumber(MNumber aNumber) |
NumberMatrix |
negate()
Every entry m(i,j) of this instance of
NumberMatrix will be
replaced by -1*m(i,j) and this instance will be returned. |
int |
rank()
Computes the rank, i.e. the maximum number of linearly independant row
vectors or column vectors.
|
MNumber |
scalarProduct(NumberMatrix aMatrix)
Returns the scalar product of this and
aMatrix as a MNumber. |
static MNumber |
scalarProduct(NumberMatrix m1,
NumberMatrix m2)
Returns the scalar product of
m1 and m2 as a MNumber. |
NumberMatrix |
setAsLinearMapping(NumberTuple[] domain,
NumberTuple[] range)
Author Matthias Holschneider
generates a matrix that if interpretd as linear operator maps domain[i] into range[i] |
NumberMatrix |
setColumnVector(int column,
NumberTuple col_vector)
Makes the entries of the
column th column of this
NumberMatrix change their values to those given in
col_vector . |
NumberMatrix |
setColumnVectors(NumberTuple[] colVectors)
This method treats the traversed
NumberTuple s as column vectors
for this NumberMatrix . |
void |
setEdited(boolean edited)
Sets the edited-flag for all entries.
|
void |
setEdited(int row,
int col,
boolean edited)
Sets the edited-flag for one cell.
|
void |
setEdited(NumberMatrix aMatrix)
Copies the "edited"-flag of every entry from
aMatrix to this matrix. |
void |
setEntry(int row,
int col,
double aValue)
Sets the given number value to the entry with the given indices.
|
void |
setEntry(int row,
int col,
MNumber v)
Copies the given number value to the entry with the given indices.
|
protected void |
setEntryClass(java.lang.Class entryClass)
changes the entryClass.
|
void |
setHidden(boolean hidden)
Sets whether this exercise object should be hidden or not.
|
void |
setLabel(java.lang.String label)
Sets the label for this exercise object.
|
protected void |
setNewSize(int numOfRows,
int numOfCols) |
void |
setNormalForm(boolean normalize) |
void |
setNormalForm(int row,
int col,
boolean normalize) |
void |
setRealType(boolean setToReal)
|
NumberMatrix |
setRowVector(int row,
NumberTuple row_vector)
Makes the entries of the
row th row of this
NumberMatrix change their values to those given in
row_vector . |
NumberMatrix |
setRowVectors(NumberTuple[] rowVectors)
This method treats the traversed
NumberTuple s as row vectors
for this NumberMatrix . |
NumberMatrix |
setToIdentity()
Sets this matrix to the identity if this matrix is square and throws
an
IllegalUsageException if it is not. |
void |
setToZero()
Sets all entries to zero (respecting the number entry class of the
matrix).
|
void |
setUsedVariables(boolean b) |
void |
setUsedVariables(int row,
int col,
boolean b) |
NumberMatrix |
shallowCopy() |
MNumber |
standardNorm()
Returns the standard norm of this matrix.
|
static MNumber |
standardNorm(NumberMatrix aMatrix)
Returns the standard norm of an arbitrary matrix.
|
NumberMatrix |
subFrom(NumberMatrix aMatrix)
Substracts
aMatrix from this matrix and returns this . |
double[] |
toDoubleArray() |
MNumber |
trace()
Returns the trace of this matrix.
|
static MNumber |
trace(NumberMatrix m)
Returns the trace of an arbitrary matrix.
|
NumberMatrix |
transposed()
Returns a transposed copy of this NumberMatrix.
|
addDimensionChangeListener, check, fireDimensionChanged, getColumnCount, getColumnFromIndex, getDimension, getEntryClass, getEntryRef, getFormater, getIndexFromEntry, getIndexFromEntry, getMathMLNode, getMathMLNode, getRowCount, getRowFromIndex, getStringMatrix, getSubMatrixView, hasSameShape, isSquare, mathematicaRepresentation, removeDimensionChangeListener, reshape, resize, setEntryRef, setFormater, setMathMLNode, setMathMLNode, toString, transpose
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getMathMLNode, getMathMLNode, setMathMLNode
public NumberMatrix(NumberMatrix matrix)
NumberMatrix
that is a deep copy of
matrix
.public NumberMatrix(java.lang.Class numberClass, int numOfCols, java.lang.Object[] entries)
NumberMatrix
with numOfCols
number
of columns and with the number entries of type numberClass
. The
numbers are the elements in entries
and the user has to care
for consistency of their number type. numOfCols
will (of course)
equal the length of any row in the NumberMatrix
and by that the
number of rows will equal entries.length / numOfCols
. Again the
user has to care for the fact that entries.length must be a multiple of
numOfCols
. The object array itsself is treated "rowwise"public NumberMatrix(java.lang.Class numberClass, int numOfCols, int numOfRows)
numberClass
and with numOfCols
columns and
numOfRows
rows.public NumberMatrix(java.lang.Class numberClass, int dimension)
numberClass
and of desired dimension.public NumberMatrix(java.lang.Class numberClass, boolean rowWise, NumberTuple[] rowcol)
numberClass
and with
the NumberTuple
-array treated as rows or columns for this
NumberMatrix
in dependence of rowWise
.public NumberMatrix(NumberTuple[] domain, NumberTuple[] range)
NumberMatrix
M that complies
to M∗domain[i] = range[i] (where ∗ means the standard
matrix multiplication and domain[i] is treated as columnvector. This method
expects that all elements in domain and range are based on the same
number type and that the domain elements are linearly independent.public NumberMatrix(org.w3c.dom.Node content) throws java.lang.Exception
mathMLnode
- a MathML/XML nodejava.lang.Exception
- when an error while instantiation occurrspublic NumberMatrix(int numOfCols, int numOfRows, double[] values)
public static NumberMatrix getIdentity(java.lang.Class entryClass, int dimension)
protected void init(int numOfCols, java.lang.Object[] entries)
Matrix
null
After setting check
is called to ensure that all entries are
valid.protected void checkEntry(java.lang.Object entry)
Matrix
null
or a subclass of entrieClass (see
getEntryClass
).checkEntry
in class Matrix
public void setRealType(boolean setToReal)
public boolean isRealType()
protected void setEntryClass(java.lang.Class entryClass)
Matrix
check
is called to ensure
that all matrix entries are valid according to the new entryClass.setEntryClass
in class Matrix
public void setEntry(int row, int col, MNumber v)
public void setEntry(int row, int col, double aValue)
public MNumber getEntry(int row, int col)
public MNumber getEntryAsNumberRef(int row, int column)
row
- an intcolumn
- an intpublic MNumber[] getEntriesAsNumberRef()
NumberMatrix
rowwise as a one
dimensional array of MNumber
s.public NumberMatrix setRowVector(int row, NumberTuple row_vector)
row
th row of this
NumberMatrix
change their values to those given in
row_vector
.public NumberMatrix setColumnVector(int column, NumberTuple col_vector)
column
th column of this
NumberMatrix
change their values to those given in
col_vector
.public NumberMatrix setRowVectors(NumberTuple[] rowVectors)
NumberTuple
s as row vectors
for this NumberMatrix
. No check about the entry classes or
any dimension will be done but the method works without side effects.
Especially this method works without creating new objects.public NumberMatrix setColumnVectors(NumberTuple[] colVectors)
NumberTuple
s as column vectors
for this NumberMatrix
. No check about the entry classes or
any dimension will be done but the method works without side effects.
Especially this method works without creating new objects.public NumberTuple getColumnVector(int columnNumber)
public NumberTuple getRowVector(int rowNumber)
public NumberTuple[] getRowVectors()
public NumberTuple[] getColumnVectors()
public void exportRow(int row, NumberTuple rowTupel)
public void exportToRows(NumberTuple[] rowTupel)
columnTupel
with the corresponding entries
in this matrix, i.e. rowTupel[i-1]
will get the entries
of the public void exportColumn(int col, NumberTuple colTupel)
public void exportToColumns(NumberTuple[] columnTupel)
columnTupel
with the corresponding entries
in this matrix, i.e. columnTupel[i-1]
will get the entries
of the public NumberMatrix setAsLinearMapping(NumberTuple[] domain, NumberTuple[] range)
public NumberMatrix setToIdentity()
IllegalUsageException
if it is not.public boolean isIdentity()
public NumberMatrix adjoint()
public NumberTuple applyTo(NumberTuple aColumnTupel)
aVector
will be changed.public void applyTo(NumberTuple aColumnTupel, NumberTuple result)
public NumberMatrix multWithNumber(MNumber aNumber)
public NumberMatrix mult(NumberMatrix aMatrix)
NumberMatrix
and aMatrix
and changes this instance, i.e.
resizes this matrix so that it fits to the product matrix' size.public static NumberMatrix mult(NumberMatrix m1, NumberMatrix m2)
public boolean isZero()
public MNumber getMaxAbsEntryRef()
public boolean isDiagonalMatrix()
public void setToZero()
public NumberMatrix addTo(NumberMatrix aMatrix)
aMatrix
to this matrix and returns this
.public NumberMatrix subFrom(NumberMatrix aMatrix)
aMatrix
from this matrix and returns this
.public NumberMatrix negate()
NumberMatrix
will be
replaced by -1*m(i,j) and this instance will be returned.public NumberMatrix shallowCopy()
public NumberMatrix deepCopy()
NumberMatrix
which has
the same dimension as this matrix and identical entries, i.e.
MNumber
instances that have the
same value as in this matrix.public NumberMatrix copyFrom(NumberMatrix aMatrix)
MNumber
entries in this matrix
will be set to the value of the corresponding entry in aMatrix
.
The "edited"-flags will not be changed in this number matrix.
This method works without creating new MNumber
s, but observe
that aMatrix
may not hold any null entries - this would leed
to a NullPointerException
.public NumberMatrix copyFrom(NumberMatrix aMatrix, boolean copyEditedFlags)
MNumber
entries in this matrix
will be set to the value of the corresponding entry in aMatrix
.
The "edited"-flags will be copied to this number matrix if the flag
copyEditedFlags
is set to true
.
This method works without creating new MNumber
s, but observe
that aMatrix
may not hold any null entries - this would leed
to a NullPointerException
.public boolean isCollinear(NumberMatrix aMatrix)
NumberMatrix
is collinear to
aMatrix
, i.e. if it is a multiple of it.public NumberMatrix inverse()
NumberMatrix
will become the (mathematical)
inverse of itsself. An IllegalUsageException
will be thrown if this matrix is not square or not invertible.public MNumber determinant()
IllegalUsageException
otherwise.public NumberMatrix inverted()
IllegalUsageException
if it is not possible. This matrix remains unchanged.public NumberMatrix transposed()
public boolean isInvertible()
public int rank()
public NumberMatrix echelonForm()
public boolean isProjector()
public boolean isRotation()
public boolean isOrthogonal()
public boolean isReflection()
public double[] toDoubleArray()
protected void setNewSize(int numOfRows, int numOfCols)
setNewSize
in class Matrix
public int equalsWithErrorCounter(java.lang.Object shouldBeAMatrix)
public Polynomial getCharPoly()
public boolean isEdited()
isEdited
in interface ExerciseObjectIF
public boolean isEdited(int row, int col)
true
if the cell entry is not a MNumber
.public boolean isCompletelyEdited()
ExerciseCompoundObjectIF
isCompletelyEdited
in interface ExerciseCompoundObjectIF
public void setEdited(NumberMatrix aMatrix)
aMatrix
to this matrix.
Notice: No values will be changed.public void setEdited(int row, int col, boolean edited)
public void setEdited(boolean edited)
setEdited
in interface ExerciseObjectIF
public java.lang.String getLabel()
ExerciseObjectIF
getLabel
in interface ExerciseObjectIF
public void setLabel(java.lang.String label)
ExerciseObjectIF
setLabel
in interface ExerciseObjectIF
public java.lang.Class getNumberClass()
NumberTypeDependentIF
getNumberClass
in interface NumberTypeDependentIF
getNumberClass
in interface ExerciseObjectIF
public boolean isHidden()
ExerciseObjectIF
false
.isHidden
in interface ExerciseObjectIF
public void setHidden(boolean hidden)
ExerciseObjectIF
false
.setHidden
in interface ExerciseObjectIF
public boolean isNormalForm()
public boolean isNormalForm(int row, int col)
true
if the cell entry is not a MNumber
.public void setNormalForm(int row, int col, boolean normalize)
public void setNormalForm(boolean normalize)
public boolean getUsedVariables()
public boolean getUsedVariables(int row, int col)
true
if the cell entry is not a MNumber
.public void setUsedVariables(int row, int col, boolean b)
public void setUsedVariables(boolean b)
public MNumber trace()
public static MNumber trace(NumberMatrix m)
public MNumber scalarProduct(NumberMatrix aMatrix)
aMatrix
as a MNumber.public static MNumber scalarProduct(NumberMatrix m1, NumberMatrix m2)
m1
and m2
as a MNumber.public MNumber standardNorm()
public static MNumber standardNorm(NumberMatrix aMatrix)
public MNumber distance(NumberMatrix aMatrix)
aMatrix
.
Both matrices must have the same shape.public static MNumber distance(NumberMatrix matrix1, NumberMatrix matrix2)
Further documentation and examples can be found under www.mathletfactory.de.