jsci.maths.matrices
Class ComplexMatrix
- java.lang.Object
-
- jsci.maths.matrices.Matrix
-
- jsci.maths.matrices.AbstractComplexMatrix
-
- jsci.maths.matrices.ComplexMatrix
-
- All Implemented Interfaces:
- java.io.Serializable, Algebra.Member, Module.Member, VectorSpace.Member, Ring.Member, AbelianGroup.Member, Member
public class ComplexMatrix extends AbstractComplexMatrix
The ComplexMatrix class provides an object for encapsulating matrices containing complex numbers.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description ComplexMatrix(Complex[][] array)Constructs a matrix from an array.ComplexMatrix(ComplexVector[] array)Constructs a matrix from an array of vectors (columns).ComplexMatrix(double[][] arrayRe, double[][] arrayIm)Constructs a matrix by wrapping two arrays.ComplexMatrix(int rows, int cols)Constructs an empty matrix.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description AbstractComplexMatrixadd(AbstractComplexMatrix m)Returns the addition of this matrix and another.ComplexMatrixadd(ComplexMatrix m)AbstractComplexMatrixconjugate()Returns the complex conjugate of this matrix.AbstractComplexMatrixdirectSum(AbstractComplexMatrix m)Returns the direct sum of this matrix and another.booleanequals(AbstractComplexMatrix m, double tol)Compares two complex matrices for equality.doublefrobeniusNorm()Returns the Frobenius or Hilbert-Schmidt (l2) norm.ComplexgetElement(int i, int j)Returns an element of the matrix.doublegetImagElement(int i, int j)Returns the imag part of an element of the matrix.doublegetRealElement(int i, int j)Returns the real part of an element of the matrix.inthashCode()Returns a hashcode for this matrix.AbstractComplexMatrixhermitianAdjoint()Returns the hermitian adjoint of this matrix.AbstractDoubleMatriximag()Returns the imaginary part of this complex matrix.doubleinfNorm()Returns the l
-norm.AbstractComplexMatrixmapElements(ComplexMapping f)Applies a function on all the matrix elements.AbstractComplexMatrixmultiply(AbstractComplexMatrix m)Returns the multiplication of this matrix and another.AbstractComplexVectormultiply(AbstractComplexVector v)Returns the multiplication of a vector by this matrix.AbstractComplexMatrixmultiply(ComplexMatrix m)AbelianGroup.Membernegate()Returns the negative of this matrix.AbstractDoubleMatrixreal()Returns the real part of this complex matrix.AbstractComplexMatrixscalarDivide(Complex z)Returns the division of this matrix by a scalar.AbstractComplexMatrixscalarDivide(double x)Returns the division of this matrix by a scalar.AbstractComplexMatrixscalarMultiply(Complex z)Returns the multiplication of this matrix by a scalar.AbstractComplexMatrixscalarMultiply(double x)Returns the multiplication of this matrix by a scalar.voidsetElement(int i, int j, Complex z)Sets the value of an element of the matrix.voidsetElement(int i, int j, double x, double y)Sets the value of an element of the matrix.AbstractComplexMatrixsubtract(AbstractComplexMatrix m)Returns the subtraction of this matrix by another.ComplexMatrixsubtract(ComplexMatrix m)AbstractComplexMatrixtensor(AbstractComplexMatrix m)Returns the tensor product of this matrix and another.java.lang.StringtoString()Returns a string representing this matrix.Matrixtranspose()Returns the transpose of this matrix.-
Methods inherited from class jsci.maths.matrices.AbstractComplexMatrix
add, equals, equals, getSet, multiply, scalarDivide, scalarMultiply, scalarProduct, subtract
-
-
-
-
Constructor Detail
-
ComplexMatrix
public ComplexMatrix(int rows, int cols)Constructs an empty matrix.- Parameters:
rows- the number of rowscols- the number of columns
-
ComplexMatrix
public ComplexMatrix(double[][] arrayRe, double[][] arrayIm)Constructs a matrix by wrapping two arrays.- Parameters:
arrayRe- an array of real valuesarrayIm- an array of imaginary values
-
ComplexMatrix
public ComplexMatrix(Complex[][] array)
Constructs a matrix from an array.- Parameters:
array- an assigned value
-
ComplexMatrix
public ComplexMatrix(ComplexVector[] array)
Constructs a matrix from an array of vectors (columns).- Parameters:
array- an assigned value
-
-
Method Detail
-
equals
public boolean equals(AbstractComplexMatrix m, double tol)
Compares two complex matrices for equality.- Overrides:
equalsin classAbstractComplexMatrix- Parameters:
m- a complex matrix
-
toString
public java.lang.String toString()
Returns a string representing this matrix.- Overrides:
toStringin classAbstractComplexMatrix
-
hashCode
public int hashCode()
Returns a hashcode for this matrix.- Overrides:
hashCodein classAbstractComplexMatrix
-
real
public AbstractDoubleMatrix real()
Returns the real part of this complex matrix.- Overrides:
realin classAbstractComplexMatrix- Returns:
- a double matrix
-
imag
public AbstractDoubleMatrix imag()
Returns the imaginary part of this complex matrix.- Overrides:
imagin classAbstractComplexMatrix- Returns:
- a double matrix
-
getElement
public Complex getElement(int i, int j)
Returns an element of the matrix.- Specified by:
getElementin classAbstractComplexMatrix- Parameters:
i- row index of the elementj- column index of the element- Throws:
MatrixDimensionException- If attempting to access an invalid element.
-
getRealElement
public double getRealElement(int i, int j)Description copied from class:AbstractComplexMatrixReturns the real part of an element of the matrix.- Specified by:
getRealElementin classAbstractComplexMatrix- Parameters:
i- row index of the elementj- column index of the element
-
getImagElement
public double getImagElement(int i, int j)Description copied from class:AbstractComplexMatrixReturns the imag part of an element of the matrix.- Specified by:
getImagElementin classAbstractComplexMatrix- Parameters:
i- row index of the elementj- column index of the element
-
setElement
public void setElement(int i, int j, Complex z)Sets the value of an element of the matrix. Should only be used to initialise this matrix.- Specified by:
setElementin classAbstractComplexMatrix- Parameters:
i- row index of the elementj- column index of the elementz- a complex number- Throws:
MatrixDimensionException- If attempting to access an invalid element.
-
setElement
public void setElement(int i, int j, double x, double y)Sets the value of an element of the matrix. Should only be used to initialise this matrix.- Specified by:
setElementin classAbstractComplexMatrix- Parameters:
i- row index of the elementj- column index of the elementx- the real part of a complex numbery- the imaginary part of a complex number- Throws:
MatrixDimensionException- If attempting to access an invalid element.
-
infNorm
public double infNorm()
Returns the l
-norm.- Overrides:
infNormin classAbstractComplexMatrix
-
frobeniusNorm
public double frobeniusNorm()
Returns the Frobenius or Hilbert-Schmidt (l2) norm.- Overrides:
frobeniusNormin classAbstractComplexMatrix
-
negate
public AbelianGroup.Member negate()
Returns the negative of this matrix.- Specified by:
negatein interfaceAbelianGroup.Member- Overrides:
negatein classAbstractComplexMatrix
-
add
public AbstractComplexMatrix add(AbstractComplexMatrix m)
Returns the addition of this matrix and another.- Overrides:
addin classAbstractComplexMatrix- Parameters:
m- a complex matrix- Throws:
MatrixDimensionException- If the matrices are different sizes.
-
add
public ComplexMatrix add(ComplexMatrix m)
-
subtract
public AbstractComplexMatrix subtract(AbstractComplexMatrix m)
Returns the subtraction of this matrix by another.- Overrides:
subtractin classAbstractComplexMatrix- Parameters:
m- a complex matrix- Throws:
MatrixDimensionException- If the matrices are different sizes.
-
subtract
public ComplexMatrix subtract(ComplexMatrix m)
-
scalarMultiply
public AbstractComplexMatrix scalarMultiply(Complex z)
Returns the multiplication of this matrix by a scalar.- Overrides:
scalarMultiplyin classAbstractComplexMatrix- Parameters:
z- a complex number- Returns:
- a complex matrix
-
scalarMultiply
public AbstractComplexMatrix scalarMultiply(double x)
Returns the multiplication of this matrix by a scalar.- Overrides:
scalarMultiplyin classAbstractComplexMatrix- Parameters:
x- a double- Returns:
- a complex matrix
-
scalarDivide
public AbstractComplexMatrix scalarDivide(Complex z)
Returns the division of this matrix by a scalar.- Overrides:
scalarDividein classAbstractComplexMatrix- Parameters:
z- a complex number- Returns:
- a complex matrix
-
scalarDivide
public AbstractComplexMatrix scalarDivide(double x)
Returns the division of this matrix by a scalar.- Overrides:
scalarDividein classAbstractComplexMatrix- Parameters:
x- a double- Returns:
- a complex matrix
-
multiply
public AbstractComplexVector multiply(AbstractComplexVector v)
Returns the multiplication of a vector by this matrix.- Overrides:
multiplyin classAbstractComplexMatrix- Parameters:
v- a complex vector- Throws:
DimensionException- If the matrix and vector are incompatible.
-
multiply
public AbstractComplexMatrix multiply(AbstractComplexMatrix m)
Returns the multiplication of this matrix and another.- Overrides:
multiplyin classAbstractComplexMatrix- Parameters:
m- a complex matrix- Returns:
- an AbstractComplexMatrix or an AbstractComplexSquareMatrix as appropriate
- Throws:
MatrixDimensionException- If the matrices are incompatible.
-
multiply
public AbstractComplexMatrix multiply(ComplexMatrix m)
-
directSum
public AbstractComplexMatrix directSum(AbstractComplexMatrix m)
Returns the direct sum of this matrix and another.- Overrides:
directSumin classAbstractComplexMatrix
-
tensor
public AbstractComplexMatrix tensor(AbstractComplexMatrix m)
Returns the tensor product of this matrix and another.- Overrides:
tensorin classAbstractComplexMatrix
-
hermitianAdjoint
public AbstractComplexMatrix hermitianAdjoint()
Returns the hermitian adjoint of this matrix.- Overrides:
hermitianAdjointin classAbstractComplexMatrix- Returns:
- a complex matrix
-
conjugate
public AbstractComplexMatrix conjugate()
Returns the complex conjugate of this matrix.- Overrides:
conjugatein classAbstractComplexMatrix- Returns:
- a complex matrix
-
transpose
public Matrix transpose()
Returns the transpose of this matrix.- Overrides:
transposein classAbstractComplexMatrix- Returns:
- a complex matrix
-
mapElements
public AbstractComplexMatrix mapElements(ComplexMapping f)
Applies a function on all the matrix elements.- Overrides:
mapElementsin classAbstractComplexMatrix- Parameters:
f- a user-defined function- Returns:
- a complex matrix
-
-
DMelt 3.0 © DataMelt by jWork.ORG