hep.physics.matrix
Class SymmetricMatrix

java.lang.Object
  extended by hep.physics.matrix.SymmetricMatrix
All Implemented Interfaces:
Matrix, MutableMatrix, java.io.Serializable

public class SymmetricMatrix
extends java.lang.Object
implements MutableMatrix, java.io.Serializable

A simple implementation of a symmetric matrix. A symmmetric matrix is a square matrix for which e(i,j) == e(j,i).

Version:
$Id: SymmetricMatrix.java 9205 2006-10-24 06:06:07Z tonyj $
Author:
tonyj
See Also:
Serialized Form

Constructor Summary
SymmetricMatrix(int size)
          Creates a new instance of SymmetricMatrix with all elements set to zero.
SymmetricMatrix(int size, double[] initialValues, boolean isLower)
          Creates a new instance of SymmetricMatrix with the given initial values.
SymmetricMatrix(Matrix mIn)
          Construct a SymmetricMatrix by copying an existing matrix.
 
Method Summary
 double[] asPackedArray(boolean isLower)
          Returns the matrix as a packed array
 double det()
           
 double diagonal(int index)
          Returns the diagonal element for the given row/column
 double e(int x, int y)
          Returns a specific element
 int getNColumns()
          Returns the number of columns
 int getNRows()
          Returns the number of rows
 void incrementElement(int x, int y, double value)
          Increment a specific element
 void invert()
          Invert this matrix (into itself)
 void setElement(int x, int y, double value)
          Set a specific element
 java.lang.String toString()
           
 void transpose()
          Tranpose this matrix (into itself)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SymmetricMatrix

public SymmetricMatrix(int size)
Creates a new instance of SymmetricMatrix with all elements set to zero.

Parameters:
size - The rank of the matrix

SymmetricMatrix

public SymmetricMatrix(Matrix mIn)
Construct a SymmetricMatrix by copying an existing matrix. If the input matrix is a SymmetricMatrix it is copied exactly. Otherwise if the input matrix is square the lower left elements are copied If the matrix is not square an illegal argument exception is thrown.


SymmetricMatrix

public SymmetricMatrix(int size,
                       double[] initialValues,
                       boolean isLower)
Creates a new instance of SymmetricMatrix with the given initial values.

Parameters:
size - The rank of the matrix
initialValues - The initial values for the matrix
isLower - If true initial values must be m(0,0), m(1,0), m(1,1), ... otherwise m(0,0), m(0,1), m(0,2), ...
Method Detail

asPackedArray

public double[] asPackedArray(boolean isLower)
Returns the matrix as a packed array

Parameters:
isLower - if true array is packed m(0,0), m(1,0), m(1,1),... else m(0,0), m(0,1), m(0,2), ...

getNRows

public int getNRows()
Description copied from interface: Matrix
Returns the number of rows

Specified by:
getNRows in interface Matrix

getNColumns

public int getNColumns()
Description copied from interface: Matrix
Returns the number of columns

Specified by:
getNColumns in interface Matrix

diagonal

public double diagonal(int index)
Returns the diagonal element for the given row/column


e

public double e(int x,
                int y)
Returns a specific element

Specified by:
e in interface Matrix

setElement

public void setElement(int x,
                       int y,
                       double value)
Set a specific element

Specified by:
setElement in interface MutableMatrix

incrementElement

public void incrementElement(int x,
                             int y,
                             double value)
Increment a specific element


det

public double det()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

invert

public void invert()
            throws MatrixOp.IndeterminateMatrixException
Description copied from interface: MutableMatrix
Invert this matrix (into itself)

Specified by:
invert in interface MutableMatrix
Throws:
MatrixOp.IndeterminateMatrixException
See Also:
MatrixOp.inverse(Matrix,MutableMatrix)

transpose

public void transpose()
Description copied from interface: MutableMatrix
Tranpose this matrix (into itself)

Specified by:
transpose in interface MutableMatrix
See Also:
MatrixOp.transposed(Matrix,MutableMatrix)


Copyright © 2000-2010 FreeHEP. All Rights Reserved.