ilog.cplex.example
Class CpxSparseVector

java.lang.Object
  |
  +--ilog.cplex.example.CpxSparseVector

public class CpxSparseVector
extends java.lang.Object

Class for representing sparse vectors.


Constructor Summary
CpxSparseVector()
          create a sparse vector with no nonzeros.
CpxSparseVector(int max)
          create a sparse vector with no nonzeros.
 
Method Summary
 void add(double v, int i)
          add a nonzero with index i and coefficient value v
 void add(int i, double v)
          add a nonzero with index i and coefficient value v
 int find(int j)
          return number of nonzero with index j in the sparse vector
 int getIndex(int i)
          return index of the i'th nonzero
 int getNNZ()
          return number of nonzeros currently in the sparse vector
 double getValue(int i)
          return coefficient value of the i'th nonzero
 void remove(int n)
          remove n'th nonzero from sparse vector
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CpxSparseVector

public CpxSparseVector()
create a sparse vector with no nonzeros. The sparse vector is ready to hold 8 nonzeros without requiring a reallocation of internal buffers.

CpxSparseVector

public CpxSparseVector(int max)
create a sparse vector with no nonzeros. The sparse vector is ready to hold max nonzeros without requiring a reallocation of internal buffers.
Parameters:
max - number of nonzeros that can be added without reallocation of internal buffers.
Method Detail

getNNZ

public int getNNZ()
return number of nonzeros currently in the sparse vector

getIndex

public int getIndex(int i)
return index of the i'th nonzero

getValue

public double getValue(int i)
return coefficient value of the i'th nonzero

add

public void add(int i,
                double v)
add a nonzero with index i and coefficient value v

add

public void add(double v,
                int i)
add a nonzero with index i and coefficient value v

remove

public void remove(int n)
remove n'th nonzero from sparse vector

find

public int find(int j)
return number of nonzero with index j in the sparse vector
Returns:
number of nonzero with index j in the sparse vector. If no such nonzero is available in the sparse vector -1 will be returned.