jv.vecmath
Class PcMatrix
- java.lang.Object
-
- jv.vecmath.PcMatrix
-
- All Implemented Interfaces:
- java.io.Serializable
public class PcMatrix extends java.lang.Object implements java.io.SerializableLinear algebra class for small matrices of complex numbers.- See Also:
PdMatrix, Serialized Form- Author:
- Eike Preuss, Konrad Polthier
- Version:
- 24.03.09, 1.35 revised (kp) New methods set/getEntry added.
04.08.03, 1.30 revised (pl) Added inverse, determinant and other methods. Fixed toString. Methods now return 'this' when appropriate.
08.11.00, 1.20 revised (kp) Interface serializable added.
08.11.00, 1.10 revised (kp) Replace string formatting routines of Fmt with PuString.
20.02.00, 1.00 created (ep)
-
-
Field Summary
Fields Modifier and Type Field and Description PuComplex[][]m_dataData array containing the components of the vector.
-
Constructor Summary
Constructors Constructor and Description PcMatrix()Create a new matrix of zero size.PcMatrix(int aSize)Create a square matrix with given dimension.PcMatrix(int iSize, int jSize)Create a non-square matrix with given dimensions.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description PcMatrixadd(PcMatrix m)Add a matrix of same sizethis = this+m.PcMatrixadd(PcMatrix m1, PcMatrix m2)Set this matrix to sum of two matrices of same sizethis = m1+m2.PuComplex[]aEigenvector(PuComplex l)Matrix must be 2x2.java.lang.Objectclone()Duplicate matrix and data array.PcMatrixcopy(PcMatrix m)Copy matrix of same sizethis = m.static PcMatrixcopyNew(PcMatrix mat)Create a new matrix as clone of argument matrix.PuComplexdeterminant()Computes the determinant of the matrix.PuComplex[]eigenvalues()Compute the eigenvalues of a 2x2 matrix.PuComplexgetEntry(int i, int j)Get the component of matrix.intgetISize()Get number of rows of matrix.intgetJSize()Get number of columns of matrix.intgetSize()Get dimension of square matrix, return -1 for non-square matrices.PcMatrixinverse()Computes the inverse of 'this'booleanisSquare()Check if matrix is square.PcMatrixleftMult(PcMatrix m)Multiply with square matrix from left of same sizes usingthis = m*this.PuComplexminor(int i, int j)Computes the determinant of the matrix obtained by deleting 'i'th row and 'j'th column.PcMatrixminorMatrix(int row, int col)Computes the matrix obtained by deleting row 'row' and column 'col'.PcMatrixmult(PcMatrix m1, PcMatrix m2)Multiply two matrices of possibly different sizes usingthis = m1*m2.static PcMatrixmultNew(PcMatrix m1, PcMatrix m2)Return product of two matricesm1*m2.PcMatrixmultScalar(PcMatrix m, PuComplex scalar)Set this matrix to product of matrix with scalarthis = m*scalar.PcMatrixmultScalar(PuComplex scalar)Multiply matrix with scalarthis = this*scalar.PcMatrixrightMult(PcMatrix m)Multiply with square matrix from right of same sizes usingthis = this*m.PcMatrixsetConstant(PuComplex aValue)Set all matrix entries to a constant value.voidsetEntry(int i, int j, PuComplex value)Assign value to component of matrix, and possibly enlarge matrix if too small.PcMatrixsetIdentity()Initialize square matrix to be identity matrix.voidsetSize(int aSize)Set dimension of square matrix.voidsetSize(int iSize, int jSize)Set dimension of non-square matrix.PcMatrixsub(PcMatrix m)Subtract a matrix of same sizethis = this-m.PcMatrixsub(PcMatrix m1, PcMatrix m2)Set this matrix to difference of two matrices of same sizethis = m1-m2.java.lang.StringtoShortString()Deprecated.use toString()java.lang.StringtoString()Create a string representation of matrix.PcMatrixtranspose()Transpose a square matrix bythis = transpose(this).
-
-
-
Field Detail
-
m_data
public PuComplex[][] m_data
Data array containing the components of the vector. Array has public access for efficiency reasons in numerical computations, although method access should be preferred. Do not modify length of array directly.
-
-
Constructor Detail
-
PcMatrix
public PcMatrix()
Create a new matrix of zero size.- Version:
- 27.12.01, 1.10 revised (kp) Now allocate arrays with zero length.
-
PcMatrix
public PcMatrix(int aSize)
Create a square matrix with given dimension.
-
PcMatrix
public PcMatrix(int iSize, int jSize)Create a non-square matrix with given dimensions.
-
-
Method Detail
-
clone
public java.lang.Object clone()
Duplicate matrix and data array. Method just returns result ofcopyNew(PcMatrix).- Overrides:
clonein classjava.lang.Object- See Also:
copyNew(PcMatrix)- Version:
- 05.07.00, 1.00 created (kp)
-
copyNew
public static PcMatrix copyNew(PcMatrix mat)
Create a new matrix as clone of argument matrix.
-
getISize
public int getISize()
Get number of rows of matrix.
-
getJSize
public int getJSize()
Get number of columns of matrix.
-
getSize
public int getSize()
Get dimension of square matrix, return -1 for non-square matrices.
-
setSize
public void setSize(int aSize)
Set dimension of square matrix.
-
setSize
public void setSize(int iSize, int jSize)Set dimension of non-square matrix.
-
getEntry
public PuComplex getEntry(int i, int j)
Get the component of matrix.- Since:
- JavaView 3.99.043
- Version:
- 24.03.09, 1.00 created (kp)
-
setEntry
public void setEntry(int i, int j, PuComplex value)Assign value to component of matrix, and possibly enlarge matrix if too small.- Since:
- JavaView 3.99.043
- Version:
- 24.03.09, 1.00 created (kp)
-
isSquare
public boolean isSquare()
Check if matrix is square.
-
setIdentity
public PcMatrix setIdentity()
Initialize square matrix to be identity matrix.
-
setConstant
public PcMatrix setConstant(PuComplex aValue)
Set all matrix entries to a constant value.
-
add
public PcMatrix add(PcMatrix m1, PcMatrix m2)
Set this matrix to sum of two matrices of same sizethis = m1+m2.
-
sub
public PcMatrix sub(PcMatrix m1, PcMatrix m2)
Set this matrix to difference of two matrices of same sizethis = m1-m2.
-
multScalar
public PcMatrix multScalar(PuComplex scalar)
Multiply matrix with scalarthis = this*scalar.
-
multScalar
public PcMatrix multScalar(PcMatrix m, PuComplex scalar)
Set this matrix to product of matrix with scalarthis = m*scalar.
-
leftMult
public PcMatrix leftMult(PcMatrix m)
Multiply with square matrix from left of same sizes usingthis = m*this. Size of 'this' does not change.
-
rightMult
public PcMatrix rightMult(PcMatrix m)
Multiply with square matrix from right of same sizes usingthis = this*m. Size of 'this' does not change.
-
mult
public PcMatrix mult(PcMatrix m1, PcMatrix m2)
Multiply two matrices of possibly different sizes usingthis = m1*m2. Size of 'this' is adjusted to have number of rows equal to first factor and number of columns equal to second factor.
-
multNew
public static PcMatrix multNew(PcMatrix m1, PcMatrix m2)
Return product of two matricesm1*m2.- Since:
- JavaView 2.90.001
- Author:
- Peter Liepa
- Version:
- 10.08.03, 1.00 created (pl)
-
transpose
public PcMatrix transpose()
Transpose a square matrix bythis = transpose(this).
-
toString
public java.lang.String toString()
Create a string representation of matrix.- Overrides:
toStringin classjava.lang.Object- Version:
- 10.08.03, 2.00 revised (pl)
-
toShortString
public java.lang.String toShortString()
Deprecated. use toString()Create a short string representation of matrix with all instance variables.
-
eigenvalues
public PuComplex[] eigenvalues()
Compute the eigenvalues of a 2x2 matrix.- Returns:
- the two eigenvalues
-
minorMatrix
public PcMatrix minorMatrix(int row, int col)
Computes the matrix obtained by deleting row 'row' and column 'col'.- Returns:
- the minor matrix
- Since:
- JavaView 2.90.001
- Author:
- Peter Liepa
- Version:
- 10.08.03, 1.00 created (pl)
-
minor
public PuComplex minor(int i, int j)
Computes the determinant of the matrix obtained by deleting 'i'th row and 'j'th column.- Returns:
- the minor
- Since:
- JavaView 2.90.001
- Author:
- Peter Liepa
- Version:
- 10.08.03, 1.00 created (pl)
-
determinant
public PuComplex determinant()
Computes the determinant of the matrix.- Returns:
- the determinant if the matrix is square, otherwise null.
- Since:
- JavaView 2.90.001
- Author:
- Peter Liepa
- Version:
- 10.08.03, 1.00 created (pl)
-
inverse
public PcMatrix inverse()
Computes the inverse of 'this'- Returns:
- the inverse matrix
- Since:
- JavaView 2.90.001
- Author:
- Peter Liepa
- Version:
- 10.08.03, 1.00 created (pl)
-
-
"