com.rubecula.jquantity
Class TwoMatrix

java.lang.Object
  extended bycom.rubecula.util.Item
      extended bycom.rubecula.jquantity.Compound
          extended bycom.rubecula.jquantity.TwoMatrix
All Implemented Interfaces:
Auditable, java.lang.Cloneable, java.lang.Comparable, CompoundModel, Divisible, Identifiable, Millable, Mutable, Nameable, Normalizable, Presentable, java.io.Serializable

public class TwoMatrix
extends Compound

Class to represent a fixed size two-dimensional matrix.

Since:
V_0_5
Version:
$Revision: 1.1 $
Author:
Robin Hillyard
See Also:
Serialized Form

Field Summary
private  BaseNumber[][] _Elements
           
 
Fields inherited from class com.rubecula.jquantity.Compound
 
Fields inherited from class com.rubecula.util.Item
JQUANTITY_TEST
 
Constructor Summary
TwoMatrix(BaseNumber[][] elements, int rows, int columns)
           
TwoMatrix(int rows, int columns)
           
 
Method Summary
 Divisible factored(double factor)
          Method to yield the quotient of this divided by factor, and return it as the result.
 int[] getDimensions()
          Method to get the maximumum indices for each dimension.
 BaseNumber getElement(int[] indices)
          Method to get the value of the element specified by the indices given.
 BaseNumber getElement(int row, int column)
           
 Divisible inverse()
          Method to yield the reciprocal of this and return it as the result.
 boolean isNormal()
          Method to determine if this instance is already normalized.
static void main(java.lang.String[] args)
           
 void normalize()
          MUTATING instance method to normalize this object.
 Divisible quotient(BaseNumber divisor)
          Method to divide this by divisor and return the quotient as the result.
 void setElement(int[] indices, BaseNumber element)
          Method to set the value of the element specified by the indices given.
 void setElement(int row, int column, BaseNumber element)
           
 
Methods inherited from class com.rubecula.jquantity.Compound
audit, getIdentifier, isMutable, makePresentableInstance, present, setConstant, setIdentifier
 
Methods inherited from class com.rubecula.util.Item
audit, audit, compareTo, Debug, getClassNameShort, getType, IsDebug, present, SetDebug, test, test, toString, Wrap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.rubecula.util.Auditable
audit, audit
 

Field Detail

_Elements

private final BaseNumber[][] _Elements
Constructor Detail

TwoMatrix

public TwoMatrix(BaseNumber[][] elements,
                 int rows,
                 int columns)
Parameters:
elements -

TwoMatrix

public TwoMatrix(int rows,
                 int columns)
Parameters:
rows -
columns -
Method Detail

inverse

public Divisible inverse()
Description copied from interface: Divisible
Method to yield the reciprocal of this and return it as the result.
NOTE: it is a requirement of this method that the class of the result is the same as the class of this so that the result can be safely cast to the original class.

Returns:
the reciprocal of this.

quotient

public Divisible quotient(BaseNumber divisor)
                   throws InvalidOperandException
Description copied from interface: Divisible
Method to divide this by divisor and return the quotient as the result.
NOTE: it is a requirement of this method that the class of the result is the same as the class of this so that the result can be safely cast to the original class.
NOTE: This method is dangerous as it is possible that the divisor is a non-pure number such as a Value. Instead of using this method, it is better to use inverse and then product.

Parameters:
divisor - the number to multiply by this.
Returns:
the quotient of this divided by divisor.
Throws:
InvalidOperandException - operands are not compatible for the quotient operation. // TODO Fix it so that this method is safe (see above).

factored

public Divisible factored(double factor)
Description copied from interface: Divisible
Method to yield the quotient of this divided by factor, and return it as the result.
NOTE: it is a requirement of this method that the class of the result is the same as the class of this so that the result can be safely cast to the original class.

Parameters:
factor - the scale factor.
Returns:
the quotient of this divided by factor.

normalize

public void normalize()
Description copied from interface: Normalizable
MUTATING instance method to normalize this object. Repeated applications of this method on an object should have no effect. The effective value of this object before and after normalization must be the same.


isNormal

public boolean isNormal()
Description copied from interface: Normalizable
Method to determine if this instance is already normalized.

Returns:
true if this object is already normalized.

getElement

public BaseNumber getElement(int[] indices)
Description copied from interface: CompoundModel
Method to get the value of the element specified by the indices given.

Parameters:
indices - an array of integers giving the indices in the 0th, 1st, ... (n-1)th dimensions of the Compound, respectively.
Returns:
the value of element [i,j,k,...] where the i,j,k,... are given in the array indices.

setElement

public void setElement(int[] indices,
                       BaseNumber element)
Description copied from interface: CompoundModel
Method to set the value of the element specified by the indices given.

Parameters:
indices - an array of integers giving the indices in the 0th, 1st, ... (n-1)th dimensions of the Compound, respectively.

getDimensions

public int[] getDimensions()
Description copied from interface: CompoundModel
Method to get the maximumum indices for each dimension.

Returns:
an array of integers giving the max value for the 0th, 1st, ... (n-1)th dimensions of the Compound, respectively.

getElement

public BaseNumber getElement(int row,
                             int column)

setElement

public void setElement(int row,
                       int column,
                       BaseNumber element)

main

public static void main(java.lang.String[] args)