net.sourceforge.combean.mathprog.linalg
Class SparseVectorWithConstantPattern

Package class diagram package SparseVectorWithConstantPattern
java.lang.Object
  extended by net.sourceforge.combean.mathprog.linalg.SparseVectorWithConstantPattern
All Implemented Interfaces:
SparseVec<NoLabel>, SparseVector

public class SparseVectorWithConstantPattern
extends Object
implements SparseVector

A vector which has a constant non-zero value only in a block with indices that follow a simple arithmetic progression. A simple example is a vector with a non-zero consecutive block like v = [0, ..., 0, 2, 2, ..., 2, 0, ... 0]. A more complex example would be w = [0, ..., 0, 3, 0, 3, 0, ..., 3, 0, ... 0], where we would have an arithmetic progression with length 2.


Constructor Summary
SparseVectorWithConstantPattern(int dim, double val)
          Construct a vector with a constant value everywhere.
SparseVectorWithConstantPattern(int dim, double val, int from, int to)
          Construct a vector with a constant value in a consecutive block.
SparseVectorWithConstantPattern(int dim, double val, int from, int to, int incr)
          Construct a vector with a constant value in a arithmetic progression.
 
Method Summary
 int getDimension()
          Get the dimension of the vector.
 int getFrom()
           
 int getIncrement()
           
 int getNumIterations()
          Return the number of entries of the vector through which the iterator returned by getIterator() iterates.
 int getTo()
           
 double getVal()
           
 VectorIterator<NoLabel> iterator()
          Get an iterator which iterates through all non-zero entries of the vector.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SparseVectorWithConstantPattern

public SparseVectorWithConstantPattern(int dim,
                                       double val)
Construct a vector with a constant value everywhere.

Parameters:
dim - dimension of the vector
val - the constant value of all elements of the vector.

SparseVectorWithConstantPattern

public SparseVectorWithConstantPattern(int dim,
                                       double val,
                                       int from,
                                       int to)
Construct a vector with a constant value in a consecutive block.

Parameters:
dim - dimension of the vector
val - the constant value of all elements of the vector.
from - the start index of the non-zero block
to - the end index of the non-zero block

SparseVectorWithConstantPattern

public SparseVectorWithConstantPattern(int dim,
                                       double val,
                                       int from,
                                       int to,
                                       int incr)
Construct a vector with a constant value in a arithmetic progression.

Parameters:
dim - dimension of the vector
val - the constant value of all non-elements of the vector.
from - the start index of the non-zero block
to - the end index of the non-zero block
incr - the increment of the arithmetic progression
Method Detail

getDimension

public int getDimension()
Description copied from interface: SparseVector
Get the dimension of the vector.

Specified by:
getDimension in interface SparseVector
Returns:
the dimension of the vector.

iterator

public VectorIterator<NoLabel> iterator()
Description copied from interface: SparseVec
Get an iterator which iterates through all non-zero entries of the vector. The iteration must stop after exactly getNumNonZeroEntries() steps. An implementation may choose to also return zero entries during the iteration. In that case, these entries must also be counted by getNumIterations(); The iteration does not have to return the values in order of increasing indices.

Specified by:
iterator in interface SparseVec<NoLabel>
Returns:
an iterator for the non-zero entries.

getNumIterations

public int getNumIterations()
Description copied from interface: SparseVec
Return the number of entries of the vector through which the iterator returned by getIterator() iterates.

Specified by:
getNumIterations in interface SparseVec<NoLabel>
Returns:
the number of iterations of getIterator.

getFrom

public final int getFrom()
Returns:
Returns the from.

getTo

public final int getTo()
Returns:
Returns the to.

getVal

public final double getVal()
Returns:
Returns the val.

getIncrement

public final int getIncrement()
Returns:
Returns the increment.