JavaView® v2.00.008

jv.vecmath
Class PdMatrix

java.lang.Object
  |
  +--jv.vecmath.PdMatrix
All Implemented Interfaces:
java.io.Serializable

public class PdMatrix
extends java.lang.Object
implements java.io.Serializable

Linear algebra class for small matrices of doubles. For methods on large matrices see PnMatrix.

Version:
08.11.00, 1.20 revised (kp) Replace string formatting routines of Fmt with PuString.
07.09.99, 1.10 revised (kp) Some new methods added.
00.00.97, 1.00 created (kp)
Author:
Konrad Polthier
See Also:
PnMatrix, Serialized Form

Field Summary
 double[][] m_data
          Data array containing the components of the vector.
protected  int m_iSize
          Number of rows of matrix, equal to m_size and m_jSize for square matrices.
protected  int m_jSize
          Number of columns of matrix, equal to m_size and m_iSize for square matrices.
 
Constructor Summary
PdMatrix()
          Create a new matrix of zero size.
PdMatrix(double[][] x)
          Constructs a matrix having same size and given initial data as given array.
PdMatrix(int aSize)
          Create a square matrix with given dimension.
PdMatrix(int iSize, int jSize)
          Create a non-square matrix with given dimensions.
 
Method Summary
 void add(PdMatrix m)
           
 void add(PdMatrix m1, PdMatrix m2)
           
 boolean adjoint(PdVector v)
          this = v * v^t.
 boolean adjoint(PdVector v, PdVector w)
          this = v * w^t.
 java.lang.Object clone()
          Duplicate matrix and data array.
 void copy(PdMatrix m)
           
static boolean copy(PdMatrix[] dataDest, int destInd, PdMatrix[] dataSrc, int srcInd, int size)
           
static PdMatrix copyNew(PdMatrix mat)
          Create a new matrix as clone of argument matrix.
static PdMatrix[] copyNew(PdMatrix[] data)
           
static PdMatrix[] copyNew(PdMatrix[] data, int size)
           
 double det()
          Compute determinant square matrix with dimensions less or equal three.
 double det33()
          Compute determinant of (3*3) left upper block of matrix.
static PdMatrix expandComponents(PdMatrix mat, int dim)
          Create a bigger matrix such that each original entry expands to a (dim, dim)-diagonal matrix.
 double[][] getEntries()
          Return a copy of content of matrix as array of arrays of doubles.
 double getEntry(int i, int j)
          Get the component of matrix.
 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.
static int getSpaceDim(double[][] point)
          Returns the dimension of the spanned space.
 boolean invert()
          Invert a square matrix of dimension less than five by this = inverse(this).
 boolean invert(PdMatrix m)
          Invert a square matrix of dimension less than five by this = inverse(m).
 boolean invert34(PdMatrix m)
          Invert the top-left 3x4 square of a matrix44 in place.
 boolean invertTopLeft(PdMatrix m, int aSubSize)
          Invert the top-left subSize x subSize square of a matrix in place.
 boolean isSquare()
          Check if matrix is square.
 void leftMult(PdMatrix m)
          Multiply with square matrix from left of same sizes using this = m*this.
 void mult(PdMatrix m1, PdMatrix m2)
          Multiply two matrices of possibly different sizes using this = m1*m2.
 void multScalar(double scalar)
           
 void multScalar(PdMatrix m, double scalar)
           
static PdMatrix[] realloc(PdMatrix[] data, int arraySize)
           
static PdMatrix[] realloc(PdMatrix[] data, int arraySize, int iSize, int jSize)
           
 void rightMult(PdMatrix m)
          Multiply with square matrix from right of same sizes using this = this*m.
 void set(double[][] x)
          Assign values of array, and adjust length of matrix if different from length of array.
 void setColumn(int aColumn, PdVector aVector)
          Set column vector of matrix.
 void setColumns(PdVector[] aVector)
          Fill matrix with array of column vectors.
 void setConstant(double aValue)
          Set all matrix entries to a constant value.
 void setDiagonal(PdVector diag)
          Set diagonal entries of a square matrix to components of a given vector.
 void setEntry(int i, int j, double value)
          Assign value to component of matrix, and possibly enlarge matrix if too small.
 void setIdentity()
          Initialize square matrix to be identity matrix.
 void setRow(int aRow, PdVector aVector)
          Set row vector of matrix.
 void setRows(PdVector[] aVector)
          Fill matrix with array of row vectors.
 void setSize(int aSize)
          Set dimension of square matrix.
 void setSize(int iSize, int jSize)
          Set dimension of non-square matrix.
 void sub(PdMatrix m)
           
 void sub(PdMatrix m1, PdMatrix 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).
 void transpose(PdMatrix m)
          Transpose a square matrix by this = transpose(m).
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_iSize

protected int m_iSize
Number of rows of matrix, equal to m_size and m_jSize for square matrices.

m_jSize

protected int m_jSize
Number of columns of matrix, equal to m_size and m_iSize for square matrices.

m_data

public double[][] 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

PdMatrix

public PdMatrix()
Create a new matrix of zero size.

PdMatrix

public PdMatrix(int aSize)
Create a square matrix with given dimension.

PdMatrix

public PdMatrix(int iSize,
                int jSize)
Create a non-square matrix with given dimensions.

PdMatrix

public PdMatrix(double[][] x)
Constructs a matrix having same size and given initial data as given array.
Method Detail

realloc

public static PdMatrix[] realloc(PdMatrix[] data,
                                 int arraySize,
                                 int iSize,
                                 int jSize)

realloc

public static PdMatrix[] realloc(PdMatrix[] data,
                                 int arraySize)

clone

public java.lang.Object clone()
Duplicate matrix and data array. Method just returns result of copyNew(PdMatrix).
Overrides:
clone in class java.lang.Object
See Also:
copyNew(PdMatrix)

copyNew

public static PdMatrix[] copyNew(PdMatrix[] data)

copyNew

public static PdMatrix[] copyNew(PdMatrix[] data,
                                 int size)

copyNew

public static PdMatrix copyNew(PdMatrix mat)
Create a new matrix as clone of argument matrix.

copy

public static boolean copy(PdMatrix[] dataDest,
                           int destInd,
                           PdMatrix[] dataSrc,
                           int srcInd,
                           int size)

set

public void set(double[][] x)
Assign values of array, and adjust length of matrix if different from length of array.

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.

getEntries

public double[][] getEntries()
Return a copy of content of matrix as array of arrays of doubles.

getEntry

public double getEntry(int i,
                       int j)
Get the component of matrix.

setEntry

public void setEntry(int i,
                     int j,
                     double value)
Assign value to component of matrix, and possibly enlarge matrix if too small.

isSquare

public boolean isSquare()
Check if matrix is square.

setIdentity

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

setConstant

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

setDiagonal

public void setDiagonal(PdVector diag)
Set diagonal entries of a square matrix to components of a given vector. No other values of matrix are modified. Size of vector must be equal or larger than size of square matrix.
Parameters:
diag - Vector with diagonal components

setRow

public void setRow(int aRow,
                   PdVector aVector)
Set row vector of matrix. Length of vector must be equal or greater than number of columns. Dimension of matrix is not modified.

setColumn

public void setColumn(int aColumn,
                      PdVector aVector)
Set column vector of matrix. Length of vector must be equal or greater than number of rows. Dimension of matrix is not modified.

setRows

public void setRows(PdVector[] aVector)
Fill matrix with array of row vectors. Number of vectors and length of each vector must be equal or greater than corresponding sizes of matrix. Dimension of matrix is not modified.

setColumns

public void setColumns(PdVector[] aVector)
Fill matrix with array of column vectors. Number of vectors and length of each vector must be equal or greater than corresponding sizes of matrix. Dimension of matrix is not modified.

add

public void add(PdMatrix m)

add

public void add(PdMatrix m1,
                PdMatrix m2)

sub

public void sub(PdMatrix m)

sub

public void sub(PdMatrix m1,
                PdMatrix m2)

copy

public void copy(PdMatrix m)

multScalar

public void multScalar(double scalar)

multScalar

public void multScalar(PdMatrix m,
                       double scalar)

det

public double det()
Compute determinant square matrix with dimensions less or equal three.

det33

public double det33()
Compute determinant of (3*3) left upper block of matrix.

leftMult

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

rightMult

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

mult

public void mult(PdMatrix m1,
                 PdMatrix 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).

transpose

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

invert

public boolean invert()
Invert a square matrix of dimension less than five by this = inverse(this).

invert

public boolean invert(PdMatrix m)
Invert a square matrix of dimension less than five by this = inverse(m).

invertTopLeft

public boolean invertTopLeft(PdMatrix m,
                             int aSubSize)
Invert the top-left subSize x subSize square of a matrix in place.

invert34

public boolean invert34(PdMatrix m)
Invert the top-left 3x4 square of a matrix44 in place.

adjoint

public boolean adjoint(PdVector v)
this = v * v^t.

adjoint

public boolean adjoint(PdVector v,
                       PdVector w)
this = v * w^t.

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.

expandComponents

public static PdMatrix expandComponents(PdMatrix mat,
                                        int dim)
Create a bigger matrix such that each original entry expands to a (dim, dim)-diagonal matrix.

getSpaceDim

public static int getSpaceDim(double[][] point)
Returns the dimension of the spanned space. That is it computes the vectors going from the last point to the other points and then checking how many of them are linearly independent.

TODO: getSpaceDim is still not completely implemented

Parameters:
point - an array of PdVectors with the points coordinates
Returns:
an int indicating the order of the spanned space

JavaView® v2.00.008

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