|
Orbital library | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Matrix
Represents a matrix of any dimension n×m.
Rn×m = { M=(mi,j) ¦ mi,j∈R} ≅ Rn ⊗R Rm where
M = (mi,j) = | [ | m0,0 , | m0,1 , | m0,2 , | …, | m0,m-1 | ] |
m1,0 , | m1,1 , | m1,2 , | …, | m1,m-1 | |||
⋮ | ⋮ | ||||||
mn-1,0, | mn-1,1, | mn-1,2, | …, | mn-1,m-1 |
The components mi,j∈R are any arithmetic objects. If R is a true ring with 1, the square matrices (Rn×n,+,·,∙) form a unital, associative R-algebra with the laws of composition + and ∙ and the law of action ·. But it is non-commutative and has zero divisors for n≥2. The general matrices (Rn×m,+,·) form an R-module, at least, with the law of composition + and the law of action ·. If R is a field, the matrices even form an R-vector space.
If you intend to use mutable arithmetic elements, note the discussion of
mutations per reference vs. explicit cloning in Tensor.set(int[],Arithmetic)
which generally holds for all operations that set component values.
Also note that some few methods will change its instance and explicitly return this
to allow chaining of structural changes,
whilst arithmetic methods will leave a matrix unchanged but return a modified version.
Refer to the documentation of the individual methods for details.
ValueFactory.tensor(Arithmetic[][])
,
ValueFactory.valueOf(Arithmetic[][])
,
ValueFactory.valueOf(double[][])
Field Summary |
---|
Fields inherited from interface orbital.math.Arithmetic |
---|
numerical |
Method Summary | |
---|---|
Matrix |
add(Matrix B)
Adds two matrices returning a matrix. |
Matrix |
conjugate()
Returns this matrix conjugate transposed. .⊹:Rn×m→Rm×n; M↦M⊹:=tM = (ti,j) with ti,j = mj,i. |
Arithmetic |
det()
Returns the determinant of the matrix representation. |
java.awt.Dimension |
dimension()
Returns the dimension of the matrix. |
Arithmetic |
get(int i,
int j)
Returns the component value at a position (i|j). |
Vector |
getColumn(int c)
Returns the column vector view of a column. |
java.util.ListIterator |
getColumns()
Returns an iterator over the column vectors. |
Vector |
getDiagonal()
Returns the main-diagonal-vector of this square matrix. |
Vector |
getRow(int r)
Returns the row vector view of a row. |
java.util.ListIterator |
getRows()
Returns an iterator over the row vectors. |
Matrix |
insertColumns(int index,
Matrix cols)
Insert columns into this matrix. |
Matrix |
insertColumns(Matrix cols)
Append columns to this matrix. |
Matrix |
insertRows(int index,
Matrix rows)
Insert rows into this matrix. |
Matrix |
insertRows(Matrix rows)
Append rows to this matrix. |
int |
isDefinite()
Checks how definite this square matrix is. |
boolean |
isInvertible()
Checks whether this square matrix is regular. |
boolean |
isRegular()
Deprecated. Since Orbital1.1 use isInvertible() instead. |
boolean |
isSquare()
Checks whether this matrix is a square matrix of size n×n. |
boolean |
isSymmetric()
Checks whether this square matrix is symmetric. |
java.util.ListIterator |
iterator()
Returns an iterator over all components (row-wise). |
int |
linearRank()
(linear) rank of this matrix. |
Matrix |
multiply(Matrix B)
Multiplies two matrices returning a matrix. |
Matrix |
multiply(Scalar s)
Multiplies a matrix with a scalar returning a matrix. |
Vector |
multiply(Vector B)
Multiplies a matrix with a vector returning a vector. |
Real |
norm()
Returns a norm ||.|| of this arithmetic object. Returns the sub-multiplicative Frobenius norm of this matrix. |
Real |
norm(double p)
Returns the norm || ||p of this matrix. |
Matrix |
pseudoInverse()
Returns the pseudo inverse matrix A+. |
Matrix |
removeColumn(int c)
Remove a column from this matrix. |
Matrix |
removeRow(int r)
Remove a row from this matrix. |
Matrix |
scale(Scalar s)
Multiplies a matrix with a scalar returning a matrix. |
void |
set(int i,
int j,
Arithmetic mij)
Sets a component value at a position (i|j). |
void |
setColumn(int c,
Vector col)
Sets the column vector at a column. |
void |
setRow(int r,
Vector row)
Sets the row vector at a row. |
Matrix |
subMatrix(int i1,
int i2,
int j1,
int j2)
Get a sub-matrix view ranging (i1:i2,j1:j2) inclusive. |
Matrix |
subtract(Matrix B)
Subtracts two matrices returning a matrix. |
Arithmetic[][] |
toArray()
Returns an array containing all the elements in this matrix. |
Arithmetic |
trace()
Returns the trace of the matrix representation. |
Matrix |
transpose()
Returns this matrix transposed. |
Methods inherited from interface orbital.math.Tensor |
---|
add, clone, dimensions, entries, get, indices, multiply, rank, set, setSubTensor, subTensor, subTensor, subTensorTransposed, subtract, tensor |
Methods inherited from interface orbital.math.Arithmetic |
---|
add, divide, equals, inverse, isOne, isZero, minus, multiply, one, power, scale, subtract, toString, valueFactory, zero |
Method Detail |
---|
java.awt.Dimension dimension()
Arithmetic get(int i, int j)
Of course, this method only has a meaning for free modules like vector spaces.
i
- the row of the value to get.j
- the column of the value to get.
void set(int i, int j, Arithmetic mij) throws java.lang.UnsupportedOperationException
Of course, this method only has a meaning for free modules like vector spaces.
i
- the row of the value to set.j
- the column of the value to set.mij
- the value to set for the element mi,j at position (i|j)
java.lang.UnsupportedOperationException
- if this matrix is constant and does not allow this operation.java.util.ListIterator getColumns()
java.util.ListIterator getRows()
java.util.ListIterator iterator()
If you cannot avoid it, call transpose().iterator() to get an iterator over all components, column by column.
iterator
in interface Tensor
Vector getColumn(int c)
The returned vector is a structurally unmodifiable view.
For Mi,j, bindSecond(c).
Functionals.bindSecond(orbital.logic.functor.BinaryFunction, Object)
void setColumn(int c, Vector col) throws java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException
Vector getRow(int r)
The returned vector is a structurally unmodifiable view.
For Mi,j bindFirst(r).
Functionals.bindFirst(orbital.logic.functor.BinaryFunction, Object)
void setRow(int r, Vector row) throws java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException
Matrix subMatrix(int i1, int i2, int j1, int j2)
The returned matrix is a structurally unmodifiable view.
i1
- the top-most row index of the sub matrix view to get.i2
- the bottom-most row index of the sub matrix view to get.j1
- the left-most column index of the sub matrix view to get.j2
- the right-most column index of the sub matrix view to get.
M(i1:i2,j1:j2) = (mi,j)i∈{i1,…,i2},j∈{j1,…,j2} = | [ | mi1,j1, | …, | mi1,j2 | ] |
⋮ | ⋮ | ||||
mi2,j1, | …, | mi2,j2 |
Vector getDiagonal()
boolean isSquare()
boolean isSymmetric() throws java.lang.ArithmeticException
In Rn×m, symmetric is the same as self-adjoint.
java.lang.ArithmeticException
- if this is not a square matrix since only square matrices can be symmetric.boolean isInvertible() throws java.lang.ArithmeticException
true
if this matrix is invertible and false
if it is singular (linear rank<n).
java.lang.ArithmeticException
- if this is not a square matrix since only square matrices can be regular.boolean isRegular() throws java.lang.ArithmeticException
isInvertible()
instead.
java.lang.ArithmeticException
int isDefinite() throws java.lang.ArithmeticException
f.ex. a symmetric matrix is positive definite iff every main minor is > 0. i.e. ∀i∈{0,…,n-1} det A(0:i,0:i) > 0. This means that every square submatrix that includes the element a0,0 has a strictly positive determinant.
C.f. Sylvester-normal form of quadratic forms.
java.lang.ArithmeticException
- if this is not a square matrix since only square matrices can be symmetric.int linearRank()
Tensor.rank()
Real norm(double p)
||.||:Cn×m→[0,∞) is a matrix norm or consistent if it is a (vector) norm and
This method should at least implement the following induced p-norms
Real norm()
Note that the Frobenius norm is not a p-norm.
It is a norm got by identifying matrices with vectors
.
norm
in interface Normed
Double.NaN
if it is symbolic and really does not have a numeric norm
or a useful symbolic norm.Arithmetic trace() throws java.lang.ArithmeticException
The trace is invariant to conjugation (similar matrices): Tr (T-1∙A∙T) = Tr A.
java.lang.ArithmeticException
- if this is not a square matrix, since only square matrix have a trace.Arithmetic det() throws java.lang.ArithmeticException
invertible
.
The determinant is the universal alternating map
Rn×n≅(Rn)n→Λn(Rn)≅R
of the exterior product Λn(Rn).
It is denoted as |M| := det M.
det:Rn×n→R exists and is uniquely defined by | ||||||||||||||||||||||||||||
(ml) |
|
"multi-linear" (linear in each row) | ||||||||||||||||||||||||||
( ) | rank M < n ⇔ det(M)=0 | "≈alternating" | ||||||||||||||||||||||||||
(1) | det(I) = 1 | |||||||||||||||||||||||||||
⇒ Properties | ||||||||||||||||||||||||||||
( ) |
|
"skew symmetric" | ||||||||||||||||||||||||||
( ) | det(MT) = det(M) | "invariant to transposition" | ||||||||||||||||||||||||||
( ) | det(M∙N) = det(M)⋅det(N) | |||||||||||||||||||||||||||
( ) | M∈(Rn×n)× ⇔ det(M)∈R× ⇒ det(M-1) = det(M)-1 |
|||||||||||||||||||||||||||
( ) |
|
"invariant to EOP" | ||||||||||||||||||||||||||
( ) |
|
"determinant formula of Leibniz" |
The determinant is invariant to conjugation (similar matrices): det (T-1∙A∙T) = det A. A matrix is invertible if and only if its determinant is invertible. However, if the determinant is approximately zero then inverse transform operations might not carry enough numerical precision to produce meaningful results.
(det A)' = ∑i=0n-1 det (a0…ai'…an-1) where ai = (a0,i,…,an-1,i)t is the i-th column of A.
java.lang.ArithmeticException
- if this is not a square matrix, since determinant is only defined for square matrices.Matrix add(Matrix B)
Matrix subtract(Matrix B)
Matrix multiply(Matrix B)
Matrix scale(Scalar s)
Matrix multiply(Scalar s)
scale(Scalar)
Vector multiply(Vector B)
Matrix transpose()
conjugate()
Matrix conjugate()
Relative to a finite orthonormal basis .⊹ is the adjoint operator.
Complex.conjugate()
,
transpose()
Matrix pseudoInverse()
The pseudo inverse of A∈Rn×m is the matrix A+∈Rm×n that satisfies
Let A = D⋅A into a diagonal matrix U,A+ = D-1⋅A⋅A+ - I is minimal)
Matrix insertColumns(int index, Matrix cols)
cols
- a n×l matrix containing l columns to be added at the end.
Matrix insertRows(int index, Matrix rows)
rows
- a x×m matrix containing x rows to be added at the end.
Matrix insertColumns(Matrix cols)
cols
- a n×x matrix containing x columns to be added at the end.
Matrix insertRows(Matrix rows)
rows
- a x×m matrix containing x rows to be added at the end.
Matrix removeColumn(int c)
Matrix removeRow(int r)
Arithmetic[][] toArray()
Object.clone()
|
Orbital library 1.3.0: 11 Apr 2009 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |