mfc.matrix
Class AbstractComplex2By2

java.lang.Object
  extended bymfc.matrix.AbstractComplex2By2
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable
Direct Known Subclasses:
Complex2By2, HermitianComplex2By2, Moebius

public abstract class AbstractComplex2By2
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

This class is the base for all classes that are or can be represented as a complex 2-by-2 matrix.

Most of its functionallity is implemented in protected methods. This enables derived classes to specialize and omit certain functions. For example, it does not make any sense to add Moebius transformations.

To minimize the object count its 4 complex entries a,b,c,d are represented by 8 double values aRe, aIm, bRe, bIm, cRe, cIm, dRe, dIm, e.g.:

 
 [ a   b ]   [ aRe + i aIm    bRe + i bIm ] 
 [       ] = [                            ] 
 [ c   d ]   [ dRe + i dIm    dRe + i dIm ] 
 

All methods avoid the creation of temporarily used objects in their internal computations unless the opposite is stated in their descriptions.

This class has final member objects, which are used as dummy variables. Thus, it is definitely not thread-safe.

See Also:
Serialized Form

Field Summary
protected  double aIm
          entry of the matrix
protected  double aRe
          entry of the matrix
protected  double bIm
          entry of the matrix
protected  double bRe
          entry of the matrix
protected  double cIm
          entry of the matrix
protected  double cRe
          entry of the matrix
protected  double dIm
          entry of the matrix
protected  double dRe
          entry of the matrix
static double EPS
          threashold for zero tests; default is 1e-14
static double EPSILON
          Deprecated. superceded by EPS
static double EPSSQR
          the square of EPS
 
Constructor Summary
protected AbstractComplex2By2()
          creates an identity matrix
  AbstractComplex2By2(AbstractComplex2By2 m)
          creates a matrix equaling prescribed matrix
protected AbstractComplex2By2(Complex a, Complex b, Complex c, Complex d)
          creates a matrix with the prescribed entries
protected AbstractComplex2By2(double aRe, double aIm, double bRe, double bIm, double cRe, double cIm, double dRe, double dIm)
          creates a matrix with the prescribed entries
 
Method Summary
 double abs()
          returns eucleaden norm
 double absSqr()
          returns square of eucleaden norm
protected  void assign(AbstractComplex2By2 s)
          assigns this with the prescribed matrix
protected  void assign(Complex a, Complex b, Complex c, Complex d)
          assigns this with the prescribed entries
protected  void assign(double aRe, double aIm, double bRe, double bIm, double cRe, double cIm, double dRe, double dIm)
          assigns this with the prescribed entries
protected  void assignAdjoined()
          assigns this with its own adjoined
protected  void assignAdjoined(AbstractComplex2By2 a)
          assigns this with the adjoined of a
protected  void assignAdjoinedWith(AbstractComplex2By2 t)
          Assign this with t this t*.
protected  void assignAdjugate()
          assigns this with its own adjugate
protected  void assignAdjugate(AbstractComplex2By2 a)
          assigns this with the adjugate of a
protected  void assignByColumn(Complex2 column1, Complex2 column2)
          Assign this by column.
protected  void assignByEigenvectors(Complex eigenvalue1, Complex2 eigenvector1, Complex eigenvalue2, Complex2 eigenvector2)
          Assign this by prescribing eigenvectors and eigenvalues.
protected  void assignByEigenvectors(double eigenvalue1Re, double eigenvalue1Im, Complex2 eigenvector1, double eigenvalue2Re, double eigenvalue2Im, Complex2 eigenvector2)
          Assign this by prescribing eigenvectors and eigenvalues.
protected  void assignConjugate()
          assigns this with its own conjugate
protected  void assignConjugate(AbstractComplex2By2 a)
          assigns this with the conjugateative of a
protected  void assignConjugateWith(AbstractComplex2By2 t)
          Assign this with t this t-1.
protected  void assignDivide(AbstractComplex2By2 m)
          assigns this with the product of itself and inverse of m
protected  void assignDivide(AbstractComplex2By2 a, AbstractComplex2By2 b)
          assigns this with the product of a and inverse of b
protected  void assignDivide(AbstractComplex2By2 m, Complex z)
          assigns this with the product of m and 1/z
protected  void assignDivide(AbstractComplex2By2 m, double r)
          assigns this with the product of m and 1/r
protected  void assignDivide(AbstractComplex2By2 m, double x, double y)
          assigns this with the product of m and 1/(x+iy)
protected  void assignDivide(Complex z)
          assigns this with the product of itself and 1/z
protected  void assignDivide(double r)
          assigns this with the product of itself and 1/r
protected  void assignDivide(double x, double y)
          assigns this with the product of itself and 1/(x+iy)
protected  void assignIdentity()
          assigns this with the identity matrix
protected  void assignInvert()
          assigns this with its own inverse
protected  void assignInvert(AbstractComplex2By2 m)
          assigns this with the inverse of m
protected  void assignMinus(AbstractComplex2By2 a)
          subtracts a from this
protected  void assignMinus(AbstractComplex2By2 a, AbstractComplex2By2 b)
          subtracts b from a and stores the result it this
protected  void assignMinus(AbstractComplex2By2 m, Complex z)
          subtracts z to all entries of m and and assigns this with the result.
protected  void assignMinus(AbstractComplex2By2 m, double x)
          subtracts x from all entries of m and and assigns this with the result.
protected  void assignMinus(AbstractComplex2By2 m, double x, double y)
          subtracts x+iy to all entries of m and and assigns this with the result.
protected  void assignMinus(Complex z)
          subtracts z from all entries of this
protected  void assignMinus(double x)
          subtracts x from all entries of this
protected  void assignMinus(double x, double y)
          subtracts x+iy to all entries of this
protected  void assignNeg()
          assigns this with its own negative
protected  void assignNeg(AbstractComplex2By2 a)
          assigns this with the negative of a
protected  void assignNormalizeDeterminant()
          normalizes (determinant equals 1) this
protected  void assignNormalizeDeterminant(AbstractComplex2By2 m)
          assigns this with m and normalizes (determinant equals 1) it
protected  void assignPlus(AbstractComplex2By2 a)
          assigns this with the sum of itself and a
protected  void assignPlus(AbstractComplex2By2 a, AbstractComplex2By2 b)
          assigns this with the sum of a and b
protected  void assignPlus(AbstractComplex2By2 m, Complex z)
          adds z to all entries of m and and assigns this with the result.
protected  void assignPlus(AbstractComplex2By2 m, double x)
          adds x to all entries of m and and assigns this with the result.
protected  void assignPlus(AbstractComplex2By2 m, double x, double y)
          adds x+iy to all entries of m and and assigns this with the result.
protected  void assignPlus(Complex z)
          adds z to all entries of this
protected  void assignPlus(double x)
          adds x to all entries of this
protected  void assignPlus(double x, double y)
          adds x+iy to all entries of this
protected  void assignStar()
          assigns this with its own transposed and conjugated
protected  void assignStar(AbstractComplex2By2 a)
          assigns this with the transposed and conjugated of a
protected  void assignTimes(AbstractComplex2By2 a)
          assigns this with the product of itself and a
protected  void assignTimes(AbstractComplex2By2 a, AbstractComplex2By2 b)
          assigns this with the product of a and b
protected  void assignTimes(AbstractComplex2By2 m, Complex z)
          assigns this with the product of m and z
protected  void assignTimes(AbstractComplex2By2 m, double r)
          assigns this with the product of m and r
protected  void assignTimes(AbstractComplex2By2 m, double x, double y)
          assigns this with the product of m and x+iy
protected  void assignTimes(Complex z)
          returns product of this and z
protected  void assignTimes(double r)
          assigns this with the product of itself and r
protected  void assignTimes(double x, double y)
          assigns this with the product of itself and x+iy
protected  void assignTranspose()
          assigns this with its own transposed
protected  void assignTranspose(AbstractComplex2By2 a)
          assigns this with the transposed of a
protected  void assignZero()
          assigns this with the zero matrix
 Complex determinant()
          returns determinant of this
 void determinant(Complex det)
          assigns det with the determinant of this
 double dist(AbstractComplex2By2 s)
          returns eucleaden distance of this to s
 double distSqr(AbstractComplex2By2 s)
          returns square of eucleaden distance of this to s
static void divide(AbstractComplex2By2 a, AbstractComplex2By2 b, AbstractComplex2By2 c)
          multiplies a and inverse of b and stores the result in c.
 boolean equals(java.lang.Object o)
          this is considered to equal o if their euclidean distance is smaller than EPS
 Complex getA()
          returns entry a of this
 void getA(Complex a)
          assigns a with entry a of this
 Complex getB()
          returns entry b of this
 void getB(Complex b)
          assigns b with entry b of this
 Complex getC()
          returns entry c of this
 void getC(Complex c)
          assigns c with entry c of this
 Complex getD()
          returns entry d of this
 void getD(Complex d)
          assigns d with entry d of this
 Complex[] getEigenValues()
          returns array containing the two eigenvalues; the first entry contains the eigenvalue with the smaller euclidean norm.
 void getEigenValues(Complex[] ev)
          assigns the first two entries of array ev to the eigenvalues of the this; the first entry contains the eigenvalue with the smaller euclidean norm.
 void getEigenValues(Complex smallEV, Complex bigEV)
          assigns smallEV with the smaller eigenvalue of this and bigEV with the bigger; both, smallEV and bigEV, may be null.
static void minus(AbstractComplex2By2 a, AbstractComplex2By2 b, AbstractComplex2By2 c)
          subtracts b from a and stores the result in c.
 double norm()
          returns the absulate value of the bigger eigenvalue.
 double normSqr()
          returns the square of absulate value of the bigger eigenvalue.
static void plus(AbstractComplex2By2 a, AbstractComplex2By2 b, AbstractComplex2By2 c)
          adds a and b and stores the result in c.
protected  void setA(Complex a)
          sets entry a of this with a
protected  void setB(Complex b)
          sets entry b of this with b
protected  void setC(Complex c)
          sets entry c of this with c
protected  void setD(Complex d)
          sets entry d of this with d
static void times(AbstractComplex2By2 a, AbstractComplex2By2 b, AbstractComplex2By2 c)
          multiplies a and b and stores the result in c.
static void times(AbstractComplex2By2 m, Complex2 v, Complex2 w)
          Multiplies m with v and stores the result in w.
 java.lang.String toString()
           
 Complex trace()
          returns trace of this
 void trace(Complex trace)
          assigns trace with the trace of this
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EPSILON

public static final double EPSILON
Deprecated. superceded by EPS

See Also:
Constant Field Values

EPS

public static final double EPS
threashold for zero tests; default is 1e-14

See Also:
Constant Field Values

EPSSQR

public static final double EPSSQR
the square of EPS

See Also:
Constant Field Values

aRe

protected double aRe
entry of the matrix


aIm

protected double aIm
entry of the matrix


bRe

protected double bRe
entry of the matrix


bIm

protected double bIm
entry of the matrix


cRe

protected double cRe
entry of the matrix


cIm

protected double cIm
entry of the matrix


dRe

protected double dRe
entry of the matrix


dIm

protected double dIm
entry of the matrix

Constructor Detail

AbstractComplex2By2

protected AbstractComplex2By2()
creates an identity matrix


AbstractComplex2By2

protected AbstractComplex2By2(double aRe,
                              double aIm,
                              double bRe,
                              double bIm,
                              double cRe,
                              double cIm,
                              double dRe,
                              double dIm)
creates a matrix with the prescribed entries


AbstractComplex2By2

protected AbstractComplex2By2(Complex a,
                              Complex b,
                              Complex c,
                              Complex d)
creates a matrix with the prescribed entries


AbstractComplex2By2

public AbstractComplex2By2(AbstractComplex2By2 m)
creates a matrix equaling prescribed matrix

Method Detail

getA

public Complex getA()
returns entry a of this


getA

public void getA(Complex a)
assigns a with entry a of this

Parameters:
a - complex value which is assigned with entry a.

setA

protected void setA(Complex a)
sets entry a of this with a


getB

public Complex getB()
returns entry b of this


getB

public void getB(Complex b)
assigns b with entry b of this

Parameters:
b - complex value which is assigned with entry b.

setB

protected void setB(Complex b)
sets entry b of this with b


getC

public Complex getC()
returns entry c of this


getC

public void getC(Complex c)
assigns c with entry c of this

Parameters:
c - complex value which is assigned with entry c.

setC

protected void setC(Complex c)
sets entry c of this with c


getD

public Complex getD()
returns entry d of this


getD

public void getD(Complex d)
assigns d with entry d of this

Parameters:
d - complex value which is assigned with entry d.

setD

protected void setD(Complex d)
sets entry d of this with d


assignZero

protected void assignZero()
assigns this with the zero matrix


assignIdentity

protected void assignIdentity()
assigns this with the identity matrix


assign

protected void assign(double aRe,
                      double aIm,
                      double bRe,
                      double bIm,
                      double cRe,
                      double cIm,
                      double dRe,
                      double dIm)
assigns this with the prescribed entries


assign

protected void assign(Complex a,
                      Complex b,
                      Complex c,
                      Complex d)
assigns this with the prescribed entries


assign

protected void assign(AbstractComplex2By2 s)
assigns this with the prescribed matrix


assignTimes

protected void assignTimes(AbstractComplex2By2 a)
assigns this with the product of itself and a


times

public static void times(AbstractComplex2By2 a,
                         AbstractComplex2By2 b,
                         AbstractComplex2By2 c)
multiplies a and b and stores the result in c.


assignTimes

protected void assignTimes(AbstractComplex2By2 a,
                           AbstractComplex2By2 b)
assigns this with the product of a and b


assignTimes

protected void assignTimes(double r)
assigns this with the product of itself and r


assignTimes

protected void assignTimes(AbstractComplex2By2 m,
                           double r)
assigns this with the product of m and r


assignTimes

protected void assignTimes(double x,
                           double y)
assigns this with the product of itself and x+iy


assignTimes

protected void assignTimes(AbstractComplex2By2 m,
                           double x,
                           double y)
assigns this with the product of m and x+iy


assignTimes

protected void assignTimes(Complex z)
returns product of this and z


assignTimes

protected void assignTimes(AbstractComplex2By2 m,
                           Complex z)
assigns this with the product of m and z


assignDivide

protected void assignDivide(AbstractComplex2By2 m)
assigns this with the product of itself and inverse of m


divide

public static void divide(AbstractComplex2By2 a,
                          AbstractComplex2By2 b,
                          AbstractComplex2By2 c)
multiplies a and inverse of b and stores the result in c.


assignDivide

protected void assignDivide(AbstractComplex2By2 a,
                            AbstractComplex2By2 b)
assigns this with the product of a and inverse of b


assignDivide

protected void assignDivide(double r)
assigns this with the product of itself and 1/r


assignDivide

protected void assignDivide(AbstractComplex2By2 m,
                            double r)
assigns this with the product of m and 1/r


assignDivide

protected void assignDivide(double x,
                            double y)
assigns this with the product of itself and 1/(x+iy)


assignDivide

protected void assignDivide(AbstractComplex2By2 m,
                            double x,
                            double y)
assigns this with the product of m and 1/(x+iy)


assignDivide

protected void assignDivide(Complex z)
assigns this with the product of itself and 1/z


assignDivide

protected void assignDivide(AbstractComplex2By2 m,
                            Complex z)
assigns this with the product of m and 1/z


assignPlus

protected void assignPlus(AbstractComplex2By2 a)
assigns this with the sum of itself and a


plus

public static void plus(AbstractComplex2By2 a,
                        AbstractComplex2By2 b,
                        AbstractComplex2By2 c)
adds a and b and stores the result in c.


assignPlus

protected void assignPlus(AbstractComplex2By2 a,
                          AbstractComplex2By2 b)
assigns this with the sum of a and b


assignPlus

protected void assignPlus(double x)
adds x to all entries of this


assignPlus

protected void assignPlus(AbstractComplex2By2 m,
                          double x)
adds x to all entries of m and and assigns this with the result.


assignPlus

protected void assignPlus(double x,
                          double y)
adds x+iy to all entries of this


assignPlus

protected void assignPlus(AbstractComplex2By2 m,
                          double x,
                          double y)
adds x+iy to all entries of m and and assigns this with the result.


assignPlus

protected void assignPlus(Complex z)
adds z to all entries of this


assignPlus

protected void assignPlus(AbstractComplex2By2 m,
                          Complex z)
adds z to all entries of m and and assigns this with the result.


assignMinus

protected void assignMinus(AbstractComplex2By2 a)
subtracts a from this


minus

public static void minus(AbstractComplex2By2 a,
                         AbstractComplex2By2 b,
                         AbstractComplex2By2 c)
subtracts b from a and stores the result in c.


assignMinus

protected void assignMinus(AbstractComplex2By2 a,
                           AbstractComplex2By2 b)
subtracts b from a and stores the result it this


assignMinus

protected void assignMinus(double x)
subtracts x from all entries of this


assignMinus

protected void assignMinus(AbstractComplex2By2 m,
                           double x)
subtracts x from all entries of m and and assigns this with the result.


assignMinus

protected void assignMinus(double x,
                           double y)
subtracts x+iy to all entries of this


assignMinus

protected void assignMinus(AbstractComplex2By2 m,
                           double x,
                           double y)
subtracts x+iy to all entries of m and and assigns this with the result.


assignMinus

protected void assignMinus(Complex z)
subtracts z from all entries of this


assignMinus

protected void assignMinus(AbstractComplex2By2 m,
                           Complex z)
subtracts z to all entries of m and and assigns this with the result.


assignNeg

protected void assignNeg(AbstractComplex2By2 a)
assigns this with the negative of a


assignNeg

protected void assignNeg()
assigns this with its own negative


assignConjugate

protected void assignConjugate(AbstractComplex2By2 a)
assigns this with the conjugateative of a


assignConjugate

protected void assignConjugate()
assigns this with its own conjugate


assignTranspose

protected void assignTranspose(AbstractComplex2By2 a)
assigns this with the transposed of a


assignTranspose

protected void assignTranspose()
assigns this with its own transposed


assignStar

protected void assignStar(AbstractComplex2By2 a)
assigns this with the transposed and conjugated of a


assignStar

protected void assignStar()
assigns this with its own transposed and conjugated


assignAdjugate

protected void assignAdjugate(AbstractComplex2By2 a)
assigns this with the adjugate of a


assignAdjugate

protected void assignAdjugate()
assigns this with its own adjugate


assignInvert

protected void assignInvert(AbstractComplex2By2 m)
assigns this with the inverse of m


assignInvert

protected void assignInvert()
assigns this with its own inverse


assignAdjoined

protected void assignAdjoined(AbstractComplex2By2 a)
assigns this with the adjoined of a


assignAdjoined

protected void assignAdjoined()
assigns this with its own adjoined


assignNormalizeDeterminant

protected void assignNormalizeDeterminant(AbstractComplex2By2 m)
assigns this with m and normalizes (determinant equals 1) it


assignNormalizeDeterminant

protected void assignNormalizeDeterminant()
normalizes (determinant equals 1) this


assignByColumn

protected void assignByColumn(Complex2 column1,
                              Complex2 column2)
Assign this by column.

Parameters:
column1 - a Complex2: the first column. Must not be null
column2 - a Complex2: the second column. Must not be null

assignConjugateWith

protected void assignConjugateWith(AbstractComplex2By2 t)
                            throws java.lang.IllegalArgumentException
Assign this with t this t-1.

Parameters:
t - an AbstractComplex2By2: the matrix with which to conjugate
Throws:
java.lang.IllegalArgumentException - if determinant of parameter t is 0.0.

assignAdjoinedWith

protected void assignAdjoinedWith(AbstractComplex2By2 t)
Assign this with t this t*.

Parameters:
t - an AbstractComplex2By2: the matrix to adjoin

assignByEigenvectors

protected void assignByEigenvectors(double eigenvalue1Re,
                                    double eigenvalue1Im,
                                    Complex2 eigenvector1,
                                    double eigenvalue2Re,
                                    double eigenvalue2Im,
                                    Complex2 eigenvector2)

Assign this by prescribing eigenvectors and eigenvalues.

The given eigenvectors must be linearly independent.

Parameters:
eigenvalue1Re - a double: real part of the first eigenvalue
eigenvalue1Im - a double: imaginary part of the first eigenvalue
eigenvector1 - a Complex2: first eigenvector
eigenvalue2Re - a double: real part of the second eigenvalue
eigenvalue2Im - a double: imaginary part of the second eigenvalue
eigenvector2 - a Complex2: second eigenvector

assignByEigenvectors

protected void assignByEigenvectors(Complex eigenvalue1,
                                    Complex2 eigenvector1,
                                    Complex eigenvalue2,
                                    Complex2 eigenvector2)

Assign this by prescribing eigenvectors and eigenvalues.

The given eigenvectors must be linearly independent.

Parameters:
eigenvalue1 - a Complex: first eigenvalue
eigenvector1 - a Complex2: first eigenvector
eigenvalue2 - a Complex: second eigenvalue
eigenvector2 - a Complex2: second eigenvector

absSqr

public final double absSqr()
returns square of eucleaden norm


abs

public final double abs()
returns eucleaden norm


distSqr

public final double distSqr(AbstractComplex2By2 s)
returns square of eucleaden distance of this to s


dist

public final double dist(AbstractComplex2By2 s)
returns eucleaden distance of this to s


determinant

public final Complex determinant()
returns determinant of this


determinant

public final void determinant(Complex det)
assigns det with the determinant of this

Parameters:
det - complex value which is assigned with the determinant

trace

public final Complex trace()
returns trace of this


trace

public final void trace(Complex trace)
assigns trace with the trace of this

Parameters:
trace - complex value which is assigned with the trace

normSqr

public final double normSqr()
returns the square of absulate value of the bigger eigenvalue. It creates a temporarily used instance of Complex


norm

public final double norm()
returns the absulate value of the bigger eigenvalue. It creates one temporarily used instance of Complex


getEigenValues

public final void getEigenValues(Complex smallEV,
                                 Complex bigEV)
assigns smallEV with the smaller eigenvalue of this and bigEV with the bigger; both, smallEV and bigEV, may be null.


getEigenValues

public final void getEigenValues(Complex[] ev)
assigns the first two entries of array ev to the eigenvalues of the this; the first entry contains the eigenvalue with the smaller euclidean norm. if an entry of the array is null an instance of Complex is created.


getEigenValues

public final Complex[] getEigenValues()
returns array containing the two eigenvalues; the first entry contains the eigenvalue with the smaller euclidean norm.


equals

public boolean equals(java.lang.Object o)
this is considered to equal o if their euclidean distance is smaller than EPS


toString

public java.lang.String toString()

times

public static void times(AbstractComplex2By2 m,
                         Complex2 v,
                         Complex2 w)
Multiplies m with v and stores the result in w.