JavaView® v2.12

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.Serializable

Linear algebra class for small matrices of complex numbers.

Version:
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)
Author:
Eike Preuss
See Also:
PdMatrix, Serialized Form

Field Summary
 PuComplex[][] m_data
          Data array containing the components of the vector.
 
Constructor Summary
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
 void add(PcMatrix m)
           
 void add(PcMatrix m1, PcMatrix m2)
           
 PuComplex[] aEigenvector(PuComplex l)
          Matrix must be 2x2.
 java.lang.Object clone()
          Duplicate matrix and data array.
 void copy(PcMatrix m)
           
static PcMatrix copyNew(PcMatrix mat)
          Create a new matrix as clone of argument matrix.
 PuComplex[] eigenvalues()
          Matrix must be 2x2.
 int getISize()
          Get number of rows of matrix.
 int getJSize()
          Get number of columns of matrix.
 int getSize()
          Get dimension of square matrix, return -1 for non-square matrices.
 boolean isSquare()
          Check if matrix is square.
 void leftMult(PcMatrix m)
          Multiply with square matrix from left of same sizes using this = m*this.
 void mult(PcMatrix m1, PcMatrix m2)
          Multiply two matrices of possibly different sizes using this = m1*m2.
 void multScalar(PcMatrix m, PuComplex scalar)
           
 void multScalar(PuComplex scalar)
           
 void rightMult(PcMatrix m)
          Multiply with square matrix from right of same sizes using this = this*m.
 void setConstant(PuComplex aValue)
          Set all matrix entries to a constant value.
 void setIdentity()
          Initialize square matrix to be identity matrix.
 void setSize(int aSize)
          Set dimension of square matrix.
 void setSize(int iSize, int jSize)
          Set dimension of non-square matrix.
 void sub(PcMatrix m)
           
 void sub(PcMatrix m1, PcMatrix m2)
           
 java.lang.String toShortString()
          Create a short string representation of matrix with all instance variables.
 java.lang.String toString()
          Create a multi-line string representation with detailed information about all instance variables.
 void transpose()
          Transpose a square matrix by this = transpose(this).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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.

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 of copyNew(PcMatrix).
See Also:
copyNew(PcMatrix)

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.

isSquare

public boolean isSquare()
Check if matrix is square.

setIdentity

public void setIdentity()
Initialize square matrix to be identity matrix.

setConstant

public void setConstant(PuComplex aValue)
Set all matrix entries to a constant value.

add

public void add(PcMatrix m)

add

public void add(PcMatrix m1,
                PcMatrix m2)

sub

public void sub(PcMatrix m)

sub

public void sub(PcMatrix m1,
                PcMatrix m2)

copy

public void copy(PcMatrix m)

multScalar

public void multScalar(PuComplex scalar)

multScalar

public void multScalar(PcMatrix m,
                       PuComplex scalar)

leftMult

public void leftMult(PcMatrix m)
Multiply with square matrix from left of same sizes using this = m*this. Size of 'this' does not change.

rightMult

public void rightMult(PcMatrix m)
Multiply with square matrix from right of same sizes using this = this*m. Size of 'this' does not change.

mult

public void mult(PcMatrix m1,
                 PcMatrix m2)
Multiply two matrices of possibly different sizes using this = m1*m2. Size of 'this' is adjusted to have number of rows equal to first factor and number of columns equal to second factor.

transpose

public void transpose()
Transpose a square matrix by this = transpose(this).

toString

public java.lang.String toString()
Create a multi-line string representation with detailed information about all instance variables.
Overrides:
toString in class java.lang.Object

toShortString

public java.lang.String toShortString()
Create a short string representation of matrix with all instance variables.

eigenvalues

public PuComplex[] eigenvalues()
Matrix must be 2x2.
Returns:
the two eigenvalues

aEigenvector

public PuComplex[] aEigenvector(PuComplex l)
Matrix must be 2x2.
Parameters:
l - eigenvalue of matrix
Returns:
2-array that contains (zx,zy) of a arbitrary eigenvector of eigenvalue l; Mz = lz; first component is normalized to 1

JavaView® v2.12

The software JavaView® is copyright protected. All Rights Reserved.