sim.util.mantissa.linalg
Class SymetricalMatrix

java.lang.Object
  extended by sim.util.mantissa.linalg.Matrix
      extended by sim.util.mantissa.linalg.SquareMatrix
          extended by sim.util.mantissa.linalg.GeneralSquareMatrix
              extended by sim.util.mantissa.linalg.SymetricalMatrix
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class SymetricalMatrix
extends GeneralSquareMatrix
implements java.io.Serializable, java.lang.Cloneable

This class implements symetrical matrices of linear algebra.

This file is from the "Mantissa" Java software package found at http://www.spaceroots.org/software/mantissa/index.html. The license is included at the end of the source file.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class sim.util.mantissa.linalg.Matrix
columns, data, rows
 
Constructor Summary
SymetricalMatrix(double w, double[] a)
          Build the symetrical matrix resulting from the product w.A.At.
SymetricalMatrix(int order)
          Simple constructor.
SymetricalMatrix(int order, double[] data)
          Simple constructor.
SymetricalMatrix(SymetricalMatrix s)
          Copy constructor.
 
Method Summary
 Matrix duplicate()
          Polymorphic copy operator.
 void selfAdd(SymetricalMatrix s)
          Add a matrix to the instance.
 void selfAddWAAt(double w, double[] a)
          Add the symetrical matrix resulting from the product w.A.At to the instance.
 void selfSub(SymetricalMatrix s)
          Substract a matrix from the instance.
 void setElement(int i, int j, double value)
          Set a matrix element.
 void setElementAndSymetricalElement(int i, int j, double value)
          Set both a matrix element and its symetrical element.
 
Methods inherited from class sim.util.mantissa.linalg.GeneralSquareMatrix
getDeterminant, getRangeForColumn, getRangeForRow, selfAdd, selfSub, solve
 
Methods inherited from class sim.util.mantissa.linalg.SquareMatrix
getInverse, solve
 
Methods inherited from class sim.util.mantissa.linalg.Matrix
add, getColumns, getElement, getRows, getTranspose, mul, mul, selfMul, sub, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SymetricalMatrix

public SymetricalMatrix(int order)
Simple constructor. This constructor builds a symetrical matrix of specified order, all elements beeing zeros.

Parameters:
order - order of the matrix

SymetricalMatrix

public SymetricalMatrix(int order,
                        double[] data)
Simple constructor. Build a matrix with specified elements.

Parameters:
order - order of the matrix
data - table of the matrix elements (stored row after row)

SymetricalMatrix

public SymetricalMatrix(SymetricalMatrix s)
Copy constructor.

Parameters:
s - square matrix to copy

SymetricalMatrix

public SymetricalMatrix(double w,
                        double[] a)
Build the symetrical matrix resulting from the product w.A.At.

Parameters:
w - multiplicative factor (weight)
a - base vector used to compute the symetrical contribution
Method Detail

duplicate

public Matrix duplicate()
Description copied from class: Matrix
Polymorphic copy operator. This method build a new object of the same type of the instance. It is somewhat similar to the Object.clone() method, except that it has public access, it doesn't throw any specific exception and it returns a Matrix.

Overrides:
duplicate in class GeneralSquareMatrix
See Also:
Object.clone()

setElement

public void setElement(int i,
                       int j,
                       double value)
Set a matrix element. On symetrical matrices, setting separately elements outside of the diagonal is forbidden, so this method throws an ArrayIndexOutOfBoundsException in this case. The setElementAndSymetricalElement(int, int, double) can be used to set both elements simultaneously.

Overrides:
setElement in class GeneralSquareMatrix
Parameters:
i - row index, from 0 to rows - 1
j - column index, from 0 to cols - 1
value - value of the element
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the indices are wrong
See Also:
setElementAndSymetricalElement(int, int, double), Matrix.getElement(int, int)

setElementAndSymetricalElement

public void setElementAndSymetricalElement(int i,
                                           int j,
                                           double value)
Set both a matrix element and its symetrical element.

Parameters:
i - row index of first element (column index of second element), from 0 to order - 1
j - column index of first element (row index of second element), from 0 to order - 1
value - value of the elements
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the indices are wrong
See Also:
setElement(int, int, double), Matrix.getElement(int, int)

selfAdd

public void selfAdd(SymetricalMatrix s)
Add a matrix to the instance. This method adds a matrix to the instance. It does modify the instance.

Parameters:
s - symetrical matrix to add
Throws:
java.lang.IllegalArgumentException - if there is a dimension mismatch

selfSub

public void selfSub(SymetricalMatrix s)
Substract a matrix from the instance. This method substracts a matrix from the instance. It does modify the instance.

Parameters:
s - symetrical matrix to substract
Throws:
java.lang.IllegalArgumentException - if there is a dimension mismatch

selfAddWAAt

public void selfAddWAAt(double w,
                        double[] a)
Add the symetrical matrix resulting from the product w.A.At to the instance. This method can be used to build progressively the matrices of least square problems. The instance is modified.

Parameters:
w - multiplicative factor (weight)
a - base vector used to compute the symetrical contribution
Throws:
java.lang.IllegalArgumentException - if there is a dimension mismatch