edu.buffalo.fs7.mathlib
Class Matrix

java.lang.Object
  |
  +--edu.buffalo.fs7.mathlib.MathObject
        |
        +--edu.buffalo.fs7.mathlib.Argument
              |
              +--edu.buffalo.fs7.mathlib.Matrix
All Implemented Interfaces:
java.lang.Cloneable

public class Matrix
extends Argument

Class representing a mathematical matrix object.

See Also:
BinaryOp

Field Summary
protected  boolean conjugate
          holds conjugate information
protected  Complex[][] data
          holds the complex components
protected  int m
          holds dimension information
protected  int n
          holds dimension information
protected  boolean transpose
          holds transpose information
 
Fields inherited from class edu.buffalo.fs7.mathlib.MathObject
mathlib
 
Constructor Summary
Matrix(int n)
          constructs a zero (n x n) matrix
Matrix(int n, int m)
          constructs a zero (n x m) matrix (n rows, m columns)
Matrix(MathObject o)
          clone constructor
 
Method Summary
 java.lang.Object clone()
          clone method
 void conjugate()
          complex conjugates the matrix
 boolean equals(MathObject m1)
          equality predicate
 Complex getElement(int n, int m)
          returns the element in row n, col m.
 int m()
          returns the number of columns
 int n()
          returns the number of rows.
 void negative()
          negates the matrix
static Matrix parseMatrix(java.lang.String str)
           parses a matrix from a string.
 void setElement(int n, int m, Complex value)
          sets the element in row n, col m to a certain value.
 java.lang.String toParseableString()
          returns a parsable string representation of the matrix (complex numbers in machine precision).
 java.lang.String toString()
          returns a string representation of the object
 void transpose()
          transposes the matrix
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

data

protected Complex[][] data
holds the complex components

n

protected int n
holds dimension information

m

protected int m
holds dimension information

transpose

protected boolean transpose
holds transpose information

conjugate

protected boolean conjugate
holds conjugate information
Constructor Detail

Matrix

public Matrix(int n,
              int m)
constructs a zero (n x m) matrix (n rows, m columns)

Matrix

public Matrix(int n)
constructs a zero (n x n) matrix

Matrix

public Matrix(MathObject o)
clone constructor
Method Detail

clone

public java.lang.Object clone()
clone method
Overrides:
clone in class MathObject

parseMatrix

public static Matrix parseMatrix(java.lang.String str)
                          throws java.lang.IllegalArgumentException,
                                 java.lang.NumberFormatException

parses a matrix from a string. The matrix given by [a b c, d e f, g h i] is parsed into

a b c

d e f

g h i

The method throws an IllegalArgumentException of a NumberFormatException if the parse process fails.
Returns:
matrix

transpose

public void transpose()
transposes the matrix

conjugate

public void conjugate()
complex conjugates the matrix

negative

public void negative()
negates the matrix

equals

public boolean equals(MathObject m1)
equality predicate
Overrides:
equals in class Argument

getElement

public Complex getElement(int n,
                          int m)
returns the element in row n, col m. This method should always be used to access components, since for example the transpose method not really transposes the matrix, but rater sets a flag.
Parameters:
n - row
m - col
Returns:
component

setElement

public void setElement(int n,
                       int m,
                       Complex value)
sets the element in row n, col m to a certain value. This method should always be used to access components, since for example the transpose method not really transposes the matrix, but rater sets a flag.
Parameters:
n - row
m - col
value - new component value

n

public int n()
returns the number of rows.

m

public int m()
returns the number of columns

toString

public java.lang.String toString()
returns a string representation of the object
Overrides:
toString in class MathObject
Following copied from class: edu.buffalo.fs7.mathlib.MathObject
See Also:
MathObject.toParseableString()

toParseableString

public java.lang.String toParseableString()
returns a parsable string representation of the matrix (complex numbers in machine precision).
Overrides:
toParseableString in class MathObject
Following copied from class: edu.buffalo.fs7.mathlib.MathObject
See Also:
MathObject.toString()