drasys.or.matrix.complex
Class ContiguousVector

java.lang.Object
  |
  +--drasys.or.matrix.complex.ComplexContainer
        |
        +--drasys.or.matrix.complex.Vect
              |
              +--drasys.or.matrix.complex.ContiguousVector
Direct Known Subclasses:
DenseVector

public class ContiguousVector
extends Vect
implements ContiguousVectorI, SizableVectorI

A dense resizable vector of complex values.

References:

Matrix Computations (Johns Hopkins Studies in the Mathematical Sciences)
    Gene H. Golub, Charles F. Van Loan (Contributor) / Paperback / Published 1996
Numerical Recipes in C : The Art of Scientific Computing
    William H. Press, et al / Hardcover / Published 1993
Parallel Algorithms for Matrix Computations
    K.A. Gallivan / Paperback / Published 1990

See Also:
Serialized Form

Fields inherited from class drasys.or.matrix.complex.ComplexContainer
_epsilon, _globalEpsilon
 
Constructor Summary
ContiguousVector()
          Create an empty dense vector with size zero and capacity 10.
ContiguousVector(double[] array)
          Create a new dense vector and copy the contents from 'array'.
ContiguousVector(double[] array, boolean useArrayInternally)
          Create a new dense vector from 'array'.
ContiguousVector(double[] real, double[] imag)
          Create a new dense vector and copy the contents from 'real' and 'imag'.
ContiguousVector(int size)
          Create a new dense vector with explicit size.
ContiguousVector(int size, ComplexI fill)
          Create a new dense vector with explicit size and initialized to 'fill'.
ContiguousVector(int size, int capacity)
          Create a new dense vector with explicit size and capacity.
ContiguousVector(VectorI vector)
          Create a new dense vector copying the contents of 'vector'.
 
Method Summary
 void addElement(ComplexI value)
          Adds a new element to the end of the vector.
 int capacity()
          Returns the number of elements the vector can hold before allocating memory.
 Complex elementAt(int index)
          Returns an element's value by its index.
 Complex elementAt(int index, Complex results)
          Returns an element's value by its index.
 java.util.Enumeration elements()
          Returns an enumeration of the elements in the matrix.
 double[] getArray()
          Returns a new two-dimensional array containing the values in matrix.
 int getBegin()
          Returns the offset of the first element into the internal array.
 int getIncrement()
          Returns the increment between elements in the internal array.
 int getOffset(int index)
          Returns an element's offset into the value array.
 double[] getValueArray()
          Returns the internal array which holds the values.
 boolean isNull(int index)
          Always returns 'false'.
 void setCapacity(int capacity)
          Insures the vector can hold 'capacity' elements without reallocating memory.
 void setElementAt(int index, ComplexI value)
          Sets an element's value by its index.
 void setElements(ComplexI value)
          Sets the value of all the non-null elements.
 void setSize(int size)
          Sets the size of the vector.
 int size()
          Returns the number of elements in the vector.
 int sizeOfElements()
          Returns the number of non-null elements in the vector.
 ContiguousVectorI subvector(int begin)
          Returns a reference to the subvector.
 ContiguousVectorI subvector(int begin, int end)
          Returns a reference to the subvector.
 Complex sum(int begin, int end)
          Returns the sum of all of the selected elements in the subvector.
 Complex sumOfSquaredDifferences(int begin, int end, ComplexI scaler)
          Returns the sum the squared differences between 'scaler' and the selected elements in the subvector.
 Complex sumOfSquares(int begin, int end)
          Returns the sum of the squares of the selected elements in the subvector.
 
Methods inherited from class drasys.or.matrix.complex.Vect
equals, equals, setElements, sum, sum, sumOfSquaredDifferences, sumOfSquaredDifferences, sumOfSquares, sumOfSquares, toString
 
Methods inherited from class drasys.or.matrix.complex.ComplexContainer
equals, equals, getEpsilon, getGlobalEpsilon, setEpsilon, setGlobalEpsilon
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ContiguousVector

public ContiguousVector()
Create an empty dense vector with size zero and capacity 10.

ContiguousVector

public ContiguousVector(int size)
Create a new dense vector with explicit size.

ContiguousVector

public ContiguousVector(int size,
                        ComplexI fill)
Create a new dense vector with explicit size and initialized to 'fill'.

ContiguousVector

public ContiguousVector(int size,
                        int capacity)
Create a new dense vector with explicit size and capacity.

ContiguousVector

public ContiguousVector(double[] array)
Create a new dense vector and copy the contents from 'array'. Each complex element occupies two adjacent array positions, the real component has an even index and the imaginary component has the next higher index.
EG: complex[0] = (array[0],array[1])

ContiguousVector

public ContiguousVector(double[] array,
                        boolean useArrayInternally)
Create a new dense vector from 'array'. If 'useArrayInternally' is true then 'array' is used for the initial values array instead of a copy. Each complex element occupies two adjacent array positions, the real component has an even index and the imaginary component has the next higher index.
EG: complex[0] = (array[0],array[1])

ContiguousVector

public ContiguousVector(double[] real,
                        double[] imag)
Create a new dense vector and copy the contents from 'real' and 'imag'. Each complex element gets one component from from 'real' and one from 'imag'
EG: complex[0] = (real[0],imag[0])
If either 'real' or 'imag' is null then the associated components will be set to zero.

ContiguousVector

public ContiguousVector(VectorI vector)
Create a new dense vector copying the contents of 'vector'. Any null elements in 'vector' will be added with a value of zero.
Method Detail

setSize

public void setSize(int size)
Sets the size of the vector.
Specified by:
setSize in interface SizableVectorI

setCapacity

public void setCapacity(int capacity)
Insures the vector can hold 'capacity' elements without reallocating memory.
Specified by:
setCapacity in interface SizableVectorI

isNull

public boolean isNull(int index)
Always returns 'false'.

getArray

public double[] getArray()
Returns a new two-dimensional array containing the values in matrix. The rows of the array hold the rows of the matrix.

getOffset

public int getOffset(int index)
Returns an element's offset into the value array. Always returns 'index'.
Specified by:
getOffset in interface ContiguousVectorI

getBegin

public int getBegin()
Returns the offset of the first element into the internal array. Always '0' for this class.
Specified by:
getBegin in interface ContiguousVectorI

getIncrement

public int getIncrement()
Returns the increment between elements in the internal array. Always '1' for this class.
Specified by:
getIncrement in interface ContiguousVectorI

getValueArray

public double[] getValueArray()
Returns the internal array which holds the values.
Specified by:
getValueArray in interface ContiguousVectorI

subvector

public ContiguousVectorI subvector(int begin)
Returns a reference to the subvector.
Specified by:
subvector in interface ContiguousVectorI

subvector

public ContiguousVectorI subvector(int begin,
                                   int end)
Returns a reference to the subvector.
Specified by:
subvector in interface ContiguousVectorI

sizeOfElements

public int sizeOfElements()
Returns the number of non-null elements in the vector.

size

public int size()
Returns the number of elements in the vector.

capacity

public int capacity()
Returns the number of elements the vector can hold before allocating memory.
Specified by:
capacity in interface SizableVectorI

addElement

public void addElement(ComplexI value)
Adds a new element to the end of the vector.
Specified by:
addElement in interface SizableVectorI

setElements

public void setElements(ComplexI value)
Sets the value of all the non-null elements.

setElementAt

public void setElementAt(int index,
                         ComplexI value)
Sets an element's value by its index.

elementAt

public Complex elementAt(int index,
                         Complex results)
Returns an element's value by its index. If 'results' is null then a new object is returned.
Tags copied from interface: VectorI
Returns:
null if the element is null.

elementAt

public Complex elementAt(int index)
Returns an element's value by its index. If results is null then a new object is returned.
Tags copied from interface: VectorI
Returns:
null if the element is null.

elements

public java.util.Enumeration elements()
Returns an enumeration of the elements in the matrix. The Enumeration reuses the same object for each call to 'nextElement', so the contents must be use before getting another element.
Returns:
an enumeration whose elements are mutable and of type 'MatrixElementI'

sum

public Complex sum(int begin,
                   int end)
Returns the sum of all of the selected elements in the subvector. If 'results' is null then a new object will be created.

sumOfSquares

public Complex sumOfSquares(int begin,
                            int end)
Returns the sum of the squares of the selected elements in the subvector. If 'results' is null then a new object will be created.

sumOfSquaredDifferences

public Complex sumOfSquaredDifferences(int begin,
                                       int end,
                                       ComplexI scaler)
Returns the sum the squared differences between 'scaler' and the selected elements in the subvector. If 'results' is null then a new object will be created.


Copyright(C)1997-2000 by DRA Systems all rights reserved. OpsResearch.com