org.lsmp.djep.vectorJep
Class Dimensions

java.lang.Object
  extended by org.lsmp.djep.vectorJep.Dimensions

public class Dimensions
extends java.lang.Object

A class to represent a set of dimensions. Might be 1 for 0-dimensional numbers. [3] for a 3D vector [3,3] for a matrix

Author:
rich Created on 25-Oct-2003

Field Summary
static Dimensions ONE
           
static Dimensions THREE
           
static Dimensions TWO
           
static Dimensions UNKNOWN
           
 
Method Summary
 boolean equals(Dimensions dims2)
          Two dimensions are equal if the element of dims are the same.
 boolean equals(java.lang.Object arg)
           
 int getFirstDim()
          get the first dimension, 1 for numbers, or the length of a vector.
 int getIthDim(int i)
           
 int getLastDim()
          get the last dimension, 1 for numbers, or the length of a vector.
 int hashcode()
          apparently your should always override hashcode when you override equals (Effective Java, Bloch).
 boolean is0D()
          Is it 0D, ie a simple number.
 boolean is1D()
          Is it 1D, ie a vector [1,2,3].
 boolean is2D()
          Is it 2D, ie a matrix [[1,2,3],[4,5,6]].
 int numEles()
          The total number of elements.
 int rank()
          rank of dimensions 0 for numbers, 1 for vectors, 2 for matrices
 java.lang.String toString()
          A string representation.
static Dimensions valueOf(Dimensions inDim, int d)
          return a dimension [inDim[0],...
static Dimensions valueOf(int d)
          Factory method returns a Dimension for vector of given length.
static Dimensions valueOf(int[] dims)
          returns a dimensions with given dimensions.
static Dimensions valueOf(int d, Dimensions inDim)
          return a dimension [d,inDim[0],...
static Dimensions valueOf(int rows, int cols)
          returns dimensions for a matrix.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNKNOWN

public static final Dimensions UNKNOWN

ONE

public static final Dimensions ONE

TWO

public static final Dimensions TWO

THREE

public static final Dimensions THREE
Method Detail

valueOf

public static Dimensions valueOf(int d)
Factory method returns a Dimension for vector of given length. For 1,2,3 returns ONE,TWO or THREE otherwise create a new object.


valueOf

public static Dimensions valueOf(int rows,
                                 int cols)
returns dimensions for a matrix.


valueOf

public static Dimensions valueOf(int d,
                                 Dimensions inDim)
return a dimension [d,inDim[0],...,inDim[n]]


valueOf

public static Dimensions valueOf(Dimensions inDim,
                                 int d)
return a dimension [inDim[0],...,inDim[n],d]


valueOf

public static Dimensions valueOf(int[] dims)
returns a dimensions with given dimensions.


getFirstDim

public int getFirstDim()
get the first dimension, 1 for numbers, or the length of a vector. for a matrix [[1,2,3],[4,5,6]] first dim is number of rows eg 2


getLastDim

public int getLastDim()
get the last dimension, 1 for numbers, or the length of a vector. for a matrix [[1,2,3],[4,5,6]] last dim is number of cols eg 3


getIthDim

public int getIthDim(int i)

is0D

public boolean is0D()
Is it 0D, ie a simple number.


is1D

public boolean is1D()
Is it 1D, ie a vector [1,2,3].


is2D

public boolean is2D()
Is it 2D, ie a matrix [[1,2,3],[4,5,6]].


numEles

public int numEles()
The total number of elements. Produce of all the dimensions.


rank

public int rank()
rank of dimensions 0 for numbers, 1 for vectors, 2 for matrices


toString

public java.lang.String toString()
A string representation. Either 1,n,[m,n],[l,m,n] etc.

Overrides:
toString in class java.lang.Object

equals

public boolean equals(Dimensions dims2)
Two dimensions are equal if the element of dims are the same.


hashcode

public int hashcode()
apparently your should always override hashcode when you override equals (Effective Java, Bloch).


equals

public boolean equals(java.lang.Object arg)
Overrides:
equals in class java.lang.Object


http://www.singularsys.com/jep Copyright © 2007 Singular Systems