CoinPackedMatrix Class Reference

Sparse Matrix Base Class. More...

#include <CoinPackedMatrix.hpp>

List of all members.

Public Member Functions

Query members
double getExtraGap () const
 Return the current setting of the extra gap.
double getExtraMajor () const
 Return the current setting of the extra major.
void reserve (const int newMaxMajorDim, const CoinBigIndex newMaxSize, bool create=false)
 Reserve sufficient space for appending major-ordered vectors.
void clear ()
 Clear the data, but do not free any arrays.
bool isColOrdered () const
 Whether the packed matrix is column major ordered or not.
bool hasGaps () const
 Whether the packed matrix has gaps or not.
CoinBigIndex getNumElements () const
 Number of entries in the packed matrix.
int getNumCols () const
 Number of columns.
int getNumRows () const
 Number of rows.
const double * getElements () const
 A vector containing the elements in the packed matrix.
const int * getIndices () const
 A vector containing the minor indices of the elements in the packed matrix.
int getSizeVectorStarts () const
 The size of the vectorStarts array.
int getSizeVectorLengths () const
 The size of the vectorLengths array.
const CoinBigIndexgetVectorStarts () const
 The positions where the major-dimension vectors start in elements and indices.
const int * getVectorLengths () const
 The lengths of the major-dimension vectors.
CoinBigIndex getVectorFirst (const int i) const
 The position of the first element in the i'th major-dimension vector.
CoinBigIndex getVectorLast (const int i) const
 The position of the last element (well, one entry past the last) in the i'th major-dimension vector.
int getVectorSize (const int i) const
 The length of i'th vector.
const CoinShallowPackedVector getVector (int i) const
 Return the i'th vector in matrix.
int * getMajorIndices () const
 Returns an array containing major indices.
Modifying members.
void setDimensions (int numrows, int numcols)
 Set the dimansions of the matrix.
void setExtraGap (const double newGap)
 Set the extra gap to be allocated to the specified value.
void setExtraMajor (const double newMajor)
 Set the extra major to be allocated to the specified value.
void appendCol (const CoinPackedVectorBase &vec)
 Append a column to the end of the matrix.
void appendCol (const int vecsize, const int *vecind, const double *vecelem)
 Append a column to the end of the matrix.
void appendCols (const int numcols, const CoinPackedVectorBase *const *cols)
 Append a set of columns to the end of the matrix.
int appendCols (const int numcols, const CoinBigIndex *columnStarts, const int *row, const double *element, int numberRows=-1)
 Append a set of columns to the end of the matrix.
void appendRow (const CoinPackedVectorBase &vec)
 Append a row to the end of the matrix.
void appendRow (const int vecsize, const int *vecind, const double *vecelem)
 Append a row to the end of the matrix.
void appendRows (const int numrows, const CoinPackedVectorBase *const *rows)
 Append a set of rows to the end of the matrix.
int appendRows (const int numrows, const CoinBigIndex *rowStarts, const int *column, const double *element, int numberColumns=-1)
 Append a set of rows to the end of the matrix.
void rightAppendPackedMatrix (const CoinPackedMatrix &matrix)
 Append the argument to the "right" of the current matrix.
void bottomAppendPackedMatrix (const CoinPackedMatrix &matrix)
 Append the argument to the "bottom" of the current matrix.
void deleteCols (const int numDel, const int *indDel)
 Delete the columns whose indices are listed in indDel.
void deleteRows (const int numDel, const int *indDel)
 Delete the rows whose indices are listed in indDel.
void replaceVector (const int index, const int numReplace, const double *newElements)
 Replace the elements of a vector.
void modifyCoefficient (int row, int column, double newElement, bool keepZero=false)
 Modify one element of packed matrix.
double getCoefficient (int row, int column) const
 Return one element of packed matrix.
int compress (double threshold)
 Eliminate all elements in matrix whose absolute value is less than threshold.
int eliminateDuplicates (double threshold)
 Eliminate all duplicate AND small elements in matrix The column starts are not affected.
void orderMatrix ()
 Sort all columns so indices are increasing.in each column.
int cleanMatrix (double threshold=1.0e-20)
 Really clean up matrix.
Methods that reorganize the whole matrix
void removeGaps (double removeValue=-1.0)
 Remove the gaps from the matrix if there were any Can also remove small elements fabs() <= removeValue.
void submatrixOf (const CoinPackedMatrix &matrix, const int numMajor, const int *indMajor)
 Extract a submatrix from matrix.
void submatrixOfWithDuplicates (const CoinPackedMatrix &matrix, const int numMajor, const int *indMajor)
 Extract a submatrix from matrix.
void copyOf (const CoinPackedMatrix &rhs)
 Copy method.
void copyOf (const bool colordered, const int minor, const int major, const CoinBigIndex numels, const double *elem, const int *ind, const CoinBigIndex *start, const int *len, const double extraMajor=0.0, const double extraGap=0.0)
 Copy the arguments to the matrix.
void copyReuseArrays (const CoinPackedMatrix &rhs)
 Copy method.
void reverseOrderedCopyOf (const CoinPackedMatrix &rhs)
 Reverse copy method.
void assignMatrix (const bool colordered, const int minor, const int major, const CoinBigIndex numels, double *&elem, int *&ind, CoinBigIndex *&start, int *&len, const int maxmajor=-1, const CoinBigIndex maxsize=-1)
 Assign the arguments to the matrix.
CoinPackedMatrixoperator= (const CoinPackedMatrix &rhs)
 Assignment operator.
void reverseOrdering ()
 Reverse the ordering of the packed matrix.
void transpose ()
 Transpose the matrix.
void swap (CoinPackedMatrix &matrix)
 Swap the content of the two packed matrix.
Matrix times vector methods
void times (const double *x, double *y) const
 Return A * x in y.
void times (const CoinPackedVectorBase &x, double *y) const
 Return A * x in y.
void transposeTimes (const double *x, double *y) const
 Return x * A in y.
void transposeTimes (const CoinPackedVectorBase &x, double *y) const
 Return x * A in y.
Queries
int * countOrthoLength () const
 Count the number of entries in every minor-dimension vector and return an array containing these lengths.
void countOrthoLength (int *counts) const
 Count the number of entries in every minor-dimension vector and fill in an array containing these lengths.
int getMajorDim () const
 Major dimension.
int getMinorDim () const
 Minor dimension.
int getMaxMajorDim () const
 Current maximum for major dimension.
void dumpMatrix (const char *fname=NULL) const
 Dump the matrix on stdout.
void printMatrixElement (const int row_val, const int col_val) const
 Print a single matrix element.
Append vectors. <br>
When libosi is compiled with a COIN_DEBUG defined then these methods throws an exception if the major (minor) vector contains an index that's larger than the minor (major) dimension (-1). Otherwise the methods assume that every index fits into the matrix.

void appendMajorVector (const CoinPackedVectorBase &vec)
 Append a major-dimension vector to the end of the matrix.
void appendMajorVector (const int vecsize, const int *vecind, const double *vecelem)
 Append a major-dimension vector to the end of the matrix.
void appendMajorVectors (const int numvecs, const CoinPackedVectorBase *const *vecs)
 Append several major-dimensonvectors to the end of the matrix.
void appendMinorVector (const CoinPackedVectorBase &vec)
 Append a minor-dimension vector to the end of the matrix.
void appendMinorVector (const int vecsize, const int *vecind, const double *vecelem)
 Append a minor-dimension vector to the end of the matrix.
void appendMinorVectors (const int numvecs, const CoinPackedVectorBase *const *vecs)
 Append several minor-dimensonvectors to the end of the matrix.
Append matrices.
We'll document these methods assuming that the current matrix is column major ordered (Hence in the ...SameOrdered() methods the argument is column ordered, in the OrthoOrdered() methods the argument is row ordered.)

void majorAppendSameOrdered (const CoinPackedMatrix &matrix)
 Append the columns of the argument to the right end of this matrix.
void minorAppendSameOrdered (const CoinPackedMatrix &matrix)
 Append the columns of the argument to the bottom end of this matrix.
void majorAppendOrthoOrdered (const CoinPackedMatrix &matrix)
 Append the rows of the argument to the right end of this matrix.
void minorAppendOrthoOrdered (const CoinPackedMatrix &matrix)
 Append the rows of the argument to the bottom end of this matrix.
Delete vectors
void deleteMajorVectors (const int numDel, const int *indDel)
 Delete the major-dimension vectors whose indices are listed in indDel.
void deleteMinorVectors (const int numDel, const int *indDel)
 Delete the minor-dimension vectors whose indices are listed in indDel.
Various dot products.
void timesMajor (const double *x, double *y) const
 Return A * x (multiplied from the "right" direction) in y.
void timesMajor (const CoinPackedVectorBase &x, double *y) const
 Return A * x (multiplied from the "right" direction) in y.
void timesMinor (const double *x, double *y) const
 Return A * x (multiplied from the "right" direction) in y.
void timesMinor (const CoinPackedVectorBase &x, double *y) const
 Return A * x (multiplied from the "right" direction) in y.
Logical Operations.
template<class FloatEqual>
bool isEquivalent (const CoinPackedMatrix &rhs, const FloatEqual &eq) const
 Equivalence.
bool isEquivalent2 (const CoinPackedMatrix &rhs) const
 Equivalence.
bool isEquivalent (const CoinPackedMatrix &rhs) const
 The default equivalence test is that the entries are relatively equal.
non const methods.
This is to be used with great care when doing column generation etc

double * getMutableElements () const
 A vector containing the elements in the packed matrix.
int * getMutableIndices () const
 A vector containing the minor indices of the elements in the packed matrix.
CoinBigIndexgetMutableVectorStarts () const
 The positions where the major-dimension vectors start in elements and indices.
int * getMutableVectorLengths () const
 The lengths of the major-dimension vectors.
void setNumElements (CoinBigIndex value)
 Change size after modifying - be careful.
void nullElementArray ()
 NULLify element array - used when space is very tight.
void nullStartArray ()
 NULLify start array - used when space is very tight.
void nullLengthArray ()
 NULLify length array - used when space is very tight.
void nullIndexArray ()
 NULLify index array - used when space is very tight.
Constructors, destructors and major modifying methods
 CoinPackedMatrix ()
 Default Constructor creates an empty column ordered packed matrix.
 CoinPackedMatrix (const bool colordered, const double extraMajor, const double extraGap)
 A constructor where the ordering and the gaps are specified.
 CoinPackedMatrix (const bool colordered, const int minor, const int major, const CoinBigIndex numels, const double *elem, const int *ind, const CoinBigIndex *start, const int *len, const double extraMajor, const double extraGap)
 Default Constructor creates an empty column ordered packed matrix.
 CoinPackedMatrix (const bool colordered, const int minor, const int major, const CoinBigIndex numels, const double *elem, const int *ind, const CoinBigIndex *start, const int *len)
 Default Constructor creates an empty column ordered packed matrix.
 CoinPackedMatrix (const bool colordered, const int *rowIndices, const int *colIndices, const double *elements, CoinBigIndex numels)
 Create packed matrix from triples.
 CoinPackedMatrix (const CoinPackedMatrix &m)
 Copy constructor.
 CoinPackedMatrix (const CoinPackedMatrix &m, int extraForMajor, int extraElements, bool reverseOrdering=false)
 Copy constructor - fine tuning - allowing extra space and/or reverse ordering.
 CoinPackedMatrix (const CoinPackedMatrix &wholeModel, int numberRows, const int *whichRows, int numberColumns, const int *whichColumns)
 Subset constructor (without gaps).
virtual ~CoinPackedMatrix ()
 Destructor.

Protected Member Functions

void gutsOfDestructor ()
void gutsOfCopyOf (const bool colordered, const int minor, const int major, const CoinBigIndex numels, const double *elem, const int *ind, const CoinBigIndex *start, const int *len, const double extraMajor=0.0, const double extraGap=0.0)
void gutsOfCopyOfNoGaps (const bool colordered, const int minor, const int major, const double *elem, const int *ind, const CoinBigIndex *start)
 When no gaps we can do faster.
void gutsOfOpEqual (const bool colordered, const int minor, const int major, const CoinBigIndex numels, const double *elem, const int *ind, const CoinBigIndex *start, const int *len)
void resizeForAddingMajorVectors (const int numVec, const int *lengthVec)
void resizeForAddingMinorVectors (const int *addedEntries)
int appendMajor (const int number, const CoinBigIndex *starts, const int *index, const double *element, int numberOther=-1)
 Append a set of rows/columns to the end of the matrix.
int appendMinor (const int number, const CoinBigIndex *starts, const int *index, const double *element, int numberOther=-1)
 Append a set of rows/columns to the end of the matrix.

Protected Attributes

Data members
The data members are protected to allow access for derived classes.

bool colOrdered_
 A flag indicating whether the matrix is column or row major ordered.
double extraGap_
 This much times more space should be allocated for each major-dimension vector (with respect to the number of entries in the vector) when the matrix is resized.
double extraMajor_
 his much times more space should be allocated for major-dimension vectors when the matrix is resized.
double * element_
 List of nonzero element values.
int * index_
 List of nonzero element minor-dimension indices.
CoinBigIndexstart_
 Starting positions of major-dimension vectors.
int * length_
 Lengths of major-dimension vectors.
int majorDim_
 number of vectors in matrix
int minorDim_
 size of other dimension
CoinBigIndex size_
 the number of nonzero entries
int maxMajorDim_
 max space allocated for major-dimension
CoinBigIndex maxSize_
 max space allocated for entries

Private Member Functions

CoinBigIndex getLastStart () const

Friends

void CoinPackedMatrixUnitTest ()
 A function that tests the methods in the CoinPackedMatrix class.


Detailed Description

Sparse Matrix Base Class.

This class is used for storing a matrix by rows or columns.

The sparse represention can be completely compact or it can have "extra" space. The extra space can be added at the end of rows and/or columns. Incorporating extra space into the sparse matrix representation can improve performance in cases where new data needs to be inserted into the packed matrix.

For example if the matrix:

     3  1  0   -2   -1  0  0   -1                 
     0  2  1.1  0    0  0  0    0                       
     0  0  1    0    0  1  0    0         
     0  0  0    2.8  0  0 -1.2  0   
   5.6  0  0    0    1  0  0    1.9

  was stored by rows (with no extra space) in 
  CoinPackedMatrix r then: 
    r.getElements() returns a vector containing: 
      3 1 -2 -1 -1 2 1.1 1 1 2.8 -1.2 5.6 1 1.9 
    r.getIndices() returns a vector containing: 
      0 1  3  4  7 1 2   2 5 3    6   0   4 7 
    r.getVectorStarts() returns a vector containing: 
      0 5 7 9 11 14 
    r.getNumElements() returns 14. 
    r.getMajorDim() returns 5. 
    r.getVectorSize(0) returns 5. 
    r.getVectorSize(1) returns 2. 
    r.getVectorSize(2) returns 2. 
    r.getVectorSize(3) returns 2. 
    r.getVectorSize(4) returns 3. 
 
  If stored by columns (with no extra space) then: 
    c.getElements() returns a vector containing: 
      3 5.6 1 2 1.1 1 -2 2.8 -1 1 1 -1.2 -1 1.9 
    c.getIndices() returns a vector containing: 
      0  4  0 1 1   2  0 3    0 4 2  3    0 4 
    c.getVectorStarts() returns a vector containing: 
      0 2 4 6 8 10 11 12 14 
    c.getNumElements() returns 14. 
    c.getMajorDim() returns 8. 
  

Definition at line 61 of file CoinPackedMatrix.hpp.


Constructor & Destructor Documentation

CoinPackedMatrix::CoinPackedMatrix (  ) 

Default Constructor creates an empty column ordered packed matrix.

CoinPackedMatrix::CoinPackedMatrix ( const bool  colordered,
const double  extraMajor,
const double  extraGap 
)

A constructor where the ordering and the gaps are specified.

CoinPackedMatrix::CoinPackedMatrix ( const bool  colordered,
const int  minor,
const int  major,
const CoinBigIndex  numels,
const double *  elem,
const int *  ind,
const CoinBigIndex start,
const int *  len,
const double  extraMajor,
const double  extraGap 
)

Default Constructor creates an empty column ordered packed matrix.

CoinPackedMatrix::CoinPackedMatrix ( const bool  colordered,
const int  minor,
const int  major,
const CoinBigIndex  numels,
const double *  elem,
const int *  ind,
const CoinBigIndex start,
const int *  len 
)

Default Constructor creates an empty column ordered packed matrix.

CoinPackedMatrix::CoinPackedMatrix ( const bool  colordered,
const int *  rowIndices,
const int *  colIndices,
const double *  elements,
CoinBigIndex  numels 
)

Create packed matrix from triples.

If colordered is true then the created matrix will be column ordered. Duplicate matrix elements are allowed. The created matrix will have the sum of the duplicates.
For example if:
rowIndices[0]=2; colIndices[0]=5; elements[0]=2.0
rowIndices[1]=2; colIndices[1]=5; elements[1]=0.5
then the created matrix will contain a value of 2.5 in row 2 and column 5.
The matrix is created without gaps.

CoinPackedMatrix::CoinPackedMatrix ( const CoinPackedMatrix m  ) 

Copy constructor.

CoinPackedMatrix::CoinPackedMatrix ( const CoinPackedMatrix m,
int  extraForMajor,
int  extraElements,
bool  reverseOrdering = false 
)

Copy constructor - fine tuning - allowing extra space and/or reverse ordering.

extraForMajor is exact extra after any possible reverse ordering. extraMajor_ and extraGap_ set to zero.

CoinPackedMatrix::CoinPackedMatrix ( const CoinPackedMatrix wholeModel,
int  numberRows,
const int *  whichRows,
int  numberColumns,
const int *  whichColumns 
)

Subset constructor (without gaps).

Duplicates are allowed and order is as given

virtual CoinPackedMatrix::~CoinPackedMatrix (  )  [virtual]

Destructor.


Member Function Documentation

double CoinPackedMatrix::getExtraGap (  )  const [inline]

Return the current setting of the extra gap.

Definition at line 71 of file CoinPackedMatrix.hpp.

References extraGap_.

double CoinPackedMatrix::getExtraMajor (  )  const [inline]

Return the current setting of the extra major.

Definition at line 73 of file CoinPackedMatrix.hpp.

References extraMajor_.

void CoinPackedMatrix::reserve ( const int  newMaxMajorDim,
const CoinBigIndex  newMaxSize,
bool  create = false 
)

Reserve sufficient space for appending major-ordered vectors.

If create is true, empty columns are created (for column generation)

void CoinPackedMatrix::clear (  ) 

Clear the data, but do not free any arrays.

bool CoinPackedMatrix::isColOrdered (  )  const [inline]

Whether the packed matrix is column major ordered or not.

Definition at line 83 of file CoinPackedMatrix.hpp.

References colOrdered_.

Referenced by ClpPackedMatrix::isColOrdered(), and isEquivalent().

bool CoinPackedMatrix::hasGaps (  )  const [inline]

Whether the packed matrix has gaps or not.

Definition at line 85 of file CoinPackedMatrix.hpp.

References majorDim_, size_, and start_.

CoinBigIndex CoinPackedMatrix::getNumElements (  )  const [inline]

Number of entries in the packed matrix.

Definition at line 89 of file CoinPackedMatrix.hpp.

References size_.

Referenced by ClpPackedMatrix::getNumElements(), and isEquivalent().

int CoinPackedMatrix::getNumCols (  )  const [inline]

Number of columns.

Definition at line 91 of file CoinPackedMatrix.hpp.

References colOrdered_, majorDim_, and minorDim_.

Referenced by ClpPackedMatrix::getNumCols(), and isEquivalent().

int CoinPackedMatrix::getNumRows (  )  const [inline]

Number of rows.

Definition at line 93 of file CoinPackedMatrix.hpp.

References colOrdered_, majorDim_, and minorDim_.

Referenced by ClpPackedMatrix::getNumRows(), and isEquivalent().

const double* CoinPackedMatrix::getElements (  )  const [inline]

A vector containing the elements in the packed matrix.

Note that there might be gaps in this list, entries that do not belong to any major-dimension vector. To get the actual elements one should look at this vector together with vectorStarts and vectorLengths.

Definition at line 99 of file CoinPackedMatrix.hpp.

References element_.

Referenced by ClpPackedMatrix::getElements().

const int* CoinPackedMatrix::getIndices (  )  const [inline]

A vector containing the minor indices of the elements in the packed matrix.

Note that there might be gaps in this list, entries that do not belong to any major-dimension vector. To get the actual elements one should look at this vector together with vectorStarts and vectorLengths.

Definition at line 105 of file CoinPackedMatrix.hpp.

References index_.

Referenced by ClpPackedMatrix::getIndices().

int CoinPackedMatrix::getSizeVectorStarts (  )  const [inline]

The size of the vectorStarts array.

Definition at line 108 of file CoinPackedMatrix.hpp.

References majorDim_.

int CoinPackedMatrix::getSizeVectorLengths (  )  const [inline]

The size of the vectorLengths array.

Definition at line 110 of file CoinPackedMatrix.hpp.

References majorDim_.

const CoinBigIndex* CoinPackedMatrix::getVectorStarts (  )  const [inline]

The positions where the major-dimension vectors start in elements and indices.

Definition at line 113 of file CoinPackedMatrix.hpp.

References start_.

Referenced by ClpPackedMatrix::getVectorStarts().

const int* CoinPackedMatrix::getVectorLengths (  )  const [inline]

The lengths of the major-dimension vectors.

Definition at line 115 of file CoinPackedMatrix.hpp.

References length_.

Referenced by ClpPackedMatrix::getVectorLengths().

CoinBigIndex CoinPackedMatrix::getVectorFirst ( const int  i  )  const [inline]

The position of the first element in the i'th major-dimension vector.

Definition at line 120 of file CoinPackedMatrix.hpp.

References majorDim_, and start_.

CoinBigIndex CoinPackedMatrix::getVectorLast ( const int  i  )  const [inline]

The position of the last element (well, one entry past the last) in the i'th major-dimension vector.

Definition at line 129 of file CoinPackedMatrix.hpp.

References length_, majorDim_, and start_.

int CoinPackedMatrix::getVectorSize ( const int  i  )  const [inline]

The length of i'th vector.

Definition at line 137 of file CoinPackedMatrix.hpp.

References length_, and majorDim_.

Referenced by ClpPackedMatrix::getVectorLength().

const CoinShallowPackedVector CoinPackedMatrix::getVector ( int  i  )  const [inline]

Return the i'th vector in matrix.

Definition at line 146 of file CoinPackedMatrix.hpp.

References element_, index_, length_, majorDim_, and start_.

Referenced by isEquivalent().

int* CoinPackedMatrix::getMajorIndices (  )  const

Returns an array containing major indices.

The array is getNumElements long and if getVectorStarts() is 0,2,5 then the array would start 0,0,1,1,1,2... This method is provided to go back from a packed format to a triple format. It returns NULL if there are gaps in matrix so user should use removeGaps() if there are any gaps. It does this as this array has to match getElements() and getIndices() and because it makes no sense otherwise. The returned array is allocated with new int[], free it with delete[].

void CoinPackedMatrix::setDimensions ( int  numrows,
int  numcols 
)

Set the dimansions of the matrix.

In effect, append new empty columns/rows to the matrix. A negative number for either dimension means that that dimension doesn't change. Otherwise the new dimensions MUST be at least as large as the current ones otherwise an exception is thrown.

void CoinPackedMatrix::setExtraGap ( const double  newGap  ) 

Set the extra gap to be allocated to the specified value.

void CoinPackedMatrix::setExtraMajor ( const double  newMajor  ) 

Set the extra major to be allocated to the specified value.

void CoinPackedMatrix::appendCol ( const CoinPackedVectorBase vec  ) 

Append a column to the end of the matrix.

When libosi is compiled with a COIN_DEBUG defined then this method throws an exception if the new column contains an index that's larger than the number of rows (-1). Otherwise the method assumes that every index fits into the matrix.

void CoinPackedMatrix::appendCol ( const int  vecsize,
const int *  vecind,
const double *  vecelem 
)

Append a column to the end of the matrix.

When libosi is compiled with a COIN_DEBUG defined then this method throws an exception if the new column contains an index that's larger than the number of rows (-1). Otherwise the method assumes that every index fits into the matrix.

void CoinPackedMatrix::appendCols ( const int  numcols,
const CoinPackedVectorBase *const *  cols 
)

Append a set of columns to the end of the matrix.

When libosi is compiled with a COIN_DEBUG defined then this method throws an exception if any of the new columns contain an index that's larger than the number of rows (-1). Otherwise the method assumes that every index fits into the matrix.

int CoinPackedMatrix::appendCols ( const int  numcols,
const CoinBigIndex columnStarts,
const int *  row,
const double *  element,
int  numberRows = -1 
)

Append a set of columns to the end of the matrix.

Returns number of errors i.e. if any of the new columns contain an index that's larger than the number of rows-1 (if numberRows>0) or duplicates (if numberRows>0).

void CoinPackedMatrix::appendRow ( const CoinPackedVectorBase vec  ) 

Append a row to the end of the matrix.

When libosi is compiled with a COIN_DEBUG defined then this method throws an exception if the new row contains an index that's larger than the number of columns (-1). Otherwise the method assumes that every index fits into the matrix.

void CoinPackedMatrix::appendRow ( const int  vecsize,
const int *  vecind,
const double *  vecelem 
)

Append a row to the end of the matrix.

When libosi is compiled with a COIN_DEBUG defined then this method throws an exception if the new row contains an index that's larger than the number of columns (-1). Otherwise the method assumes that every index fits into the matrix.

void CoinPackedMatrix::appendRows ( const int  numrows,
const CoinPackedVectorBase *const *  rows 
)

Append a set of rows to the end of the matrix.

When libosi is compiled with a COIN_DEBUG defined then this method throws an exception if any of the new rows contain an index that's larger than the number of columns (-1). Otherwise the method assumes that every index fits into the matrix.

int CoinPackedMatrix::appendRows ( const int  numrows,
const CoinBigIndex rowStarts,
const int *  column,
const double *  element,
int  numberColumns = -1 
)

Append a set of rows to the end of the matrix.

Returns number of errors i.e. if any of the new rows contain an index that's larger than the number of columns-1 (if numberColumns>0) or duplicates (if numberColumns>0).

void CoinPackedMatrix::rightAppendPackedMatrix ( const CoinPackedMatrix matrix  ) 

Append the argument to the "right" of the current matrix.

Imagine this as adding new columns (don't worry about how the matrices are ordered, that is taken care of). An exception is thrown if the number of rows is different in the matrices.

void CoinPackedMatrix::bottomAppendPackedMatrix ( const CoinPackedMatrix matrix  ) 

Append the argument to the "bottom" of the current matrix.

Imagine this as adding new rows (don't worry about how the matrices are ordered, that is taken care of). An exception is thrown if the number of columns is different in the matrices.

void CoinPackedMatrix::deleteCols ( const int  numDel,
const int *  indDel 
)

Delete the columns whose indices are listed in indDel.

void CoinPackedMatrix::deleteRows ( const int  numDel,
const int *  indDel 
)

Delete the rows whose indices are listed in indDel.

void CoinPackedMatrix::replaceVector ( const int  index,
const int  numReplace,
const double *  newElements 
)

Replace the elements of a vector.

The indices remain the same. At most the number specified will be replaced. The index is between 0 and major dimension of matrix

Referenced by ClpPackedMatrix::replaceVector().

void CoinPackedMatrix::modifyCoefficient ( int  row,
int  column,
double  newElement,
bool  keepZero = false 
)

Modify one element of packed matrix.

An element may be added. This works for either ordering If the new element is zero it will be deleted unless keepZero true

Referenced by ClpPackedMatrix::modifyCoefficient().

double CoinPackedMatrix::getCoefficient ( int  row,
int  column 
) const

Return one element of packed matrix.

This works for either ordering If it is not present will return 0.0

int CoinPackedMatrix::compress ( double  threshold  ) 

Eliminate all elements in matrix whose absolute value is less than threshold.

The column starts are not affected. Returns number of elements eliminated. Elements eliminated are at end of each vector

int CoinPackedMatrix::eliminateDuplicates ( double  threshold  ) 

Eliminate all duplicate AND small elements in matrix The column starts are not affected.

Returns number of elements eliminated.

void CoinPackedMatrix::orderMatrix (  ) 

Sort all columns so indices are increasing.in each column.

int CoinPackedMatrix::cleanMatrix ( double  threshold = 1.0e-20  ) 

Really clean up matrix.

a) eliminate all duplicate AND small elements in matrix b) remove all gaps and set extraGap_ and extraMajor_ to 0.0 c) reallocate arrays and make max lengths equal to lengths d) orders elements returns number of elements eliminated

void CoinPackedMatrix::removeGaps ( double  removeValue = -1.0  ) 

Remove the gaps from the matrix if there were any Can also remove small elements fabs() <= removeValue.

void CoinPackedMatrix::submatrixOf ( const CoinPackedMatrix matrix,
const int  numMajor,
const int *  indMajor 
)

Extract a submatrix from matrix.

Those major-dimension vectors of the matrix comprise the submatrix whose indices are given in the arguments. Does not allow duplicates.

void CoinPackedMatrix::submatrixOfWithDuplicates ( const CoinPackedMatrix matrix,
const int  numMajor,
const int *  indMajor 
)

Extract a submatrix from matrix.

Those major-dimension vectors of the matrix comprise the submatrix whose indices are given in the arguments. Allows duplicates and keeps order.