CoinUtils  2.10.14
CoinPackedMatrix.hpp
Go to the documentation of this file.
1 /* $Id: CoinPackedMatrix.hpp 1560 2012-11-24 00:29:01Z lou $ */
2 // Copyright (C) 2000, International Business Machines
3 // Corporation and others. All Rights Reserved.
4 // This code is licensed under the terms of the Eclipse Public License (EPL).
5 
6 #ifndef CoinPackedMatrix_H
7 #define CoinPackedMatrix_H
8 
9 #include "CoinError.hpp"
10 #include "CoinTypes.hpp"
11 #ifndef CLP_NO_VECTOR
12 #include "CoinPackedVectorBase.hpp"
14 #else
15 class CoinRelFltEq;
16 #endif
17 
80  friend void CoinPackedMatrixUnitTest();
81 
82 public:
83 
84 
85  //---------------------------------------------------------------------------
89  inline double getExtraGap() const { return extraGap_; }
91  inline double getExtraMajor() const { return extraMajor_; }
92 
95  void reserve(const int newMaxMajorDim, const CoinBigIndex newMaxSize,
96  bool create=false);
98  void clear();
99 
101  inline bool isColOrdered() const { return colOrdered_; }
102 
104  inline bool hasGaps() const { return (size_<start_[majorDim_]) ; }
105 
107  inline CoinBigIndex getNumElements() const { return size_; }
108 
110  inline int getNumCols() const
111  { return colOrdered_ ? majorDim_ : minorDim_; }
112 
114  inline int getNumRows() const
115  { return colOrdered_ ? minorDim_ : majorDim_; }
116 
124  inline const double * getElements() const { return element_; }
125 
134  inline const int * getIndices() const { return index_; }
135 
140  inline int getSizeVectorStarts() const
141  { return ((majorDim_ > 0)?(majorDim_+1):(0)) ; }
142 
147  inline int getSizeVectorLengths() const { return majorDim_; }
148 
154  inline const CoinBigIndex * getVectorStarts() const { return start_; }
155 
160  inline const int * getVectorLengths() const { return length_; }
161 
164  CoinBigIndex getVectorFirst(const int i) const {
165 #ifndef COIN_FAST_CODE
166  if (i < 0 || i >= majorDim_)
167  throw CoinError("bad index", "vectorFirst", "CoinPackedMatrix");
168 #endif
169  return start_[i];
170  }
173  CoinBigIndex getVectorLast(const int i) const {
174 #ifndef COIN_FAST_CODE
175  if (i < 0 || i >= majorDim_)
176  throw CoinError("bad index", "vectorLast", "CoinPackedMatrix");
177 #endif
178  return start_[i] + length_[i];
179  }
181  inline int getVectorSize(const int i) const {
182 #ifndef COIN_FAST_CODE
183  if (i < 0 || i >= majorDim_)
184  throw CoinError("bad index", "vectorSize", "CoinPackedMatrix");
185 #endif
186  return length_[i];
187  }
188 #ifndef CLP_NO_VECTOR
189 
190  const CoinShallowPackedVector getVector(int i) const {
191 #ifndef COIN_FAST_CODE
192  if (i < 0 || i >= majorDim_)
193  throw CoinError("bad index", "vector", "CoinPackedMatrix");
194 #endif
196  index_ + start_[i],
197  element_ + start_[i],
198  false);
199  }
200 #endif
201 
211  int * getMajorIndices() const;
213 
214  //---------------------------------------------------------------------------
225  void setDimensions(int numrows, int numcols);
226 
228  void setExtraGap(const double newGap);
230  void setExtraMajor(const double newMajor);
231 #ifndef CLP_NO_VECTOR
232 
238  void appendCol(const CoinPackedVectorBase& vec);
239 #endif
240 
246  void appendCol(const int vecsize,
247  const int *vecind, const double *vecelem);
248 #ifndef CLP_NO_VECTOR
249 
255  void appendCols(const int numcols,
256  const CoinPackedVectorBase * const * cols);
257 #endif
258 
263  int appendCols(const int numcols,
264  const CoinBigIndex * columnStarts, const int * row,
265  const double * element, int numberRows=-1);
266 #ifndef CLP_NO_VECTOR
267 
273  void appendRow(const CoinPackedVectorBase& vec);
274 #endif
275 
281  void appendRow(const int vecsize,
282  const int *vecind, const double *vecelem);
283 #ifndef CLP_NO_VECTOR
284 
290  void appendRows(const int numrows,
291  const CoinPackedVectorBase * const * rows);
292 #endif
293 
298  int appendRows(const int numrows,
299  const CoinBigIndex * rowStarts, const int * column,
300  const double * element, int numberColumns=-1);
301 
312 
314  void deleteCols(const int numDel, const int * indDel);
316  void deleteRows(const int numDel, const int * indDel);
317 
321  void replaceVector(const int index,
322  const int numReplace, const double * newElements);
327  void modifyCoefficient(int row, int column, double newElement,
328  bool keepZero=false);
332  double getCoefficient(int row, int column) const;
333 
339  int compress(double threshold);
344  int eliminateDuplicates(double threshold);
346  void orderMatrix();
354  int cleanMatrix(double threshold=1.0e-20);
356 
357  //---------------------------------------------------------------------------
362  void removeGaps(double removeValue=-1.0);
363 
367  void submatrixOf(const CoinPackedMatrix& matrix,
368  const int numMajor, const int * indMajor);
373  const int numMajor, const int * indMajor);
374 #if 0
375 
378  void submatrixOf(const CoinPackedMatrix& matrix,
379  const int numMajor, const int * indMajor,
380  const int numMinor, const int * indMinor);
381 #endif
382 
385  void copyOf(const CoinPackedMatrix& rhs);
389  void copyOf(const bool colordered,
390  const int minor, const int major, const CoinBigIndex numels,
391  const double * elem, const int * ind,
392  const CoinBigIndex * start, const int * len,
393  const double extraMajor=0.0, const double extraGap=0.0);
398 
407 
416  void assignMatrix(const bool colordered,
417  const int minor, const int major,
418  const CoinBigIndex numels,
419  double *& elem, int *& ind,
420  CoinBigIndex *& start, int *& len,
421  const int maxmajor = -1, const CoinBigIndex maxsize = -1);
422 
423 
424 
428 
436 
446  void transpose();
447 
449  void swap(CoinPackedMatrix& matrix);
450 
452 
453  //---------------------------------------------------------------------------
459  void times(const double * x, double * y) const;
460 #ifndef CLP_NO_VECTOR
461 
463  void times(const CoinPackedVectorBase& x, double * y) const;
464 #endif
465 
468  void transposeTimes(const double * x, double * y) const;
469 #ifndef CLP_NO_VECTOR
470 
472  void transposeTimes(const CoinPackedVectorBase& x, double * y) const;
473 #endif
474 
475 
476  //---------------------------------------------------------------------------
484 
485  //-------------------------------------------------------------------------
492  int * countOrthoLength() const;
495  void countOrthoLength(int * counts) const;
498  inline int getMajorDim() const { return majorDim_; }
501  inline void setMajorDim(int value) { majorDim_ = value; }
504  inline int getMinorDim() const { return minorDim_; }
507  inline void setMinorDim(int value) { minorDim_ = value; }
511  inline int getMaxMajorDim() const { return maxMajorDim_; }
512 
515  void dumpMatrix(const char* fname = NULL) const;
516 
518  void printMatrixElement(const int row_val, const int col_val) const;
520 
521  //-------------------------------------------------------------------------
531 #ifndef CLP_NO_VECTOR
532 
534 #endif
535 
536  void appendMajorVector(const int vecsize, const int *vecind,
537  const double *vecelem);
538 #ifndef CLP_NO_VECTOR
539 
540  void appendMajorVectors(const int numvecs,
541  const CoinPackedVectorBase * const * vecs);
542 
545 #endif
546 
547  void appendMinorVector(const int vecsize, const int *vecind,
548  const double *vecelem);
549 #ifndef CLP_NO_VECTOR
550 
551  void appendMinorVectors(const int numvecs,
552  const CoinPackedVectorBase * const * vecs);
553 #endif
554 
566  void appendMinorFast(const int number,
567  const CoinBigIndex * starts, const int * index,
568  const double * element);
570 
571  //-------------------------------------------------------------------------
604 
605  //-----------------------------------------------------------------------
610  void deleteMajorVectors(const int numDel, const int * indDel);
613  void deleteMinorVectors(const int numDel, const int * indDel);
615 
616  //-----------------------------------------------------------------------
623  void timesMajor(const double * x, double * y) const;
624 #ifndef CLP_NO_VECTOR
625 
628  void timesMajor(const CoinPackedVectorBase& x, double * y) const;
629 #endif
630 
634  void timesMinor(const double * x, double * y) const;
635 #ifndef CLP_NO_VECTOR
636 
639  void timesMinor(const CoinPackedVectorBase& x, double * y) const;
640 #endif
641 
642 
643 
644  //--------------------------------------------------------------------------
647 #ifndef CLP_NO_VECTOR
648 
655  template <class FloatEqual> bool
656  isEquivalent(const CoinPackedMatrix& rhs, const FloatEqual& eq) const
657  {
658  // Both must be column order or both row ordered and must be of same size
659  if ((isColOrdered() ^ rhs.isColOrdered()) ||
660  (getNumCols() != rhs.getNumCols()) ||
661  (getNumRows() != rhs.getNumRows()) ||
662  (getNumElements() != rhs.getNumElements()))
663  return false;
664 
665  for (int i=getMajorDim()-1; i >= 0; --i) {
667  CoinShallowPackedVector rhsPv = rhs.getVector(i);
668  if ( !pv.isEquivalent(rhsPv,eq) )
669  return false;
670  }
671  return true;
672  }
673 
680  bool isEquivalent2(const CoinPackedMatrix& rhs) const;
681 #else
682 
690  bool isEquivalent(const CoinPackedMatrix& rhs, const CoinRelFltEq & eq) const;
691 #endif
692 
696  bool isEquivalent(const CoinPackedMatrix& rhs) const;
698 
699  //--------------------------------------------------------------------------
709  inline double * getMutableElements() const { return element_; }
715  inline int * getMutableIndices() const { return index_; }
716 
719  inline CoinBigIndex * getMutableVectorStarts() const { return start_; }
721  inline int * getMutableVectorLengths() const { return length_; }
723  inline void setNumElements(CoinBigIndex value)
724  { size_ = value;}
729  inline void nullElementArray() {element_=NULL;}
730 
735  inline void nullStartArray() {start_=NULL;}
736 
741  inline void nullLengthArray() {length_=NULL;}
742 
747  inline void nullIndexArray() {index_=NULL;}
749 
750  //--------------------------------------------------------------------------
755 
757  CoinPackedMatrix(const bool colordered,
758  const double extraMajor, const double extraGap);
759 
760  CoinPackedMatrix(const bool colordered,
761  const int minor, const int major, const CoinBigIndex numels,
762  const double * elem, const int * ind,
763  const CoinBigIndex * start, const int * len,
764  const double extraMajor, const double extraGap);
765 
766  CoinPackedMatrix(const bool colordered,
767  const int minor, const int major, const CoinBigIndex numels,
768  const double * elem, const int * ind,
769  const CoinBigIndex * start, const int * len);
770 
781  CoinPackedMatrix(const bool colordered,
782  const int * rowIndices,
783  const int * colIndices,
784  const double * elements,
785  CoinBigIndex numels );
786 
789 
805  int extraForMajor, int extraElements,
806  bool reverseOrdering = false) ;
807 
810  CoinPackedMatrix (const CoinPackedMatrix & wholeModel,
811  int numberRows, const int * whichRows,
812  int numberColumns, const int * whichColumns);
813 
815  virtual ~CoinPackedMatrix();
817 
841  int verifyMtx(int verbosity = 1, bool zeroesAreError = false) const ;
843 
844  //--------------------------------------------------------------------------
845 protected:
847  void gutsOfCopyOf(const bool colordered,
848  const int minor, const int major, const CoinBigIndex numels,
849  const double * elem, const int * ind,
850  const CoinBigIndex * start, const int * len,
851  const double extraMajor=0.0, const double extraGap=0.0);
853  void gutsOfCopyOfNoGaps(const bool colordered,
854  const int minor, const int major,
855  const double * elem, const int * ind,
856  const CoinBigIndex * start);
857  void gutsOfOpEqual(const bool colordered,
858  const int minor, const int major, const CoinBigIndex numels,
859  const double * elem, const int * ind,
860  const CoinBigIndex * start, const int * len);
861  void resizeForAddingMajorVectors(const int numVec, const int * lengthVec);
862  void resizeForAddingMinorVectors(const int * addedEntries);
863 
873  int appendMajor(const int number,
874  const CoinBigIndex * starts, const int * index,
875  const double * element, int numberOther=-1);
885  int appendMinor(const int number,
886  const CoinBigIndex * starts, const int * index,
887  const double * element, int numberOther=-1);
888 
889 private:
890  inline CoinBigIndex getLastStart() const {
891  return majorDim_ == 0 ? 0 : start_[majorDim_];
892  }
893 
894  //--------------------------------------------------------------------------
895 protected:
905  double extraGap_;
909  double extraMajor_;
910 
913  double *element_;
916  int *index_;
920  int *length_;
921 
928 
934 };
935 
936 //#############################################################################
944 void
946 
947 #endif
CoinPackedMatrix::copyReuseArrays
void copyReuseArrays(const CoinPackedMatrix &rhs)
Copy method.
CoinPackedMatrix::size_
CoinBigIndex size_
the number of nonzero entries
Definition: CoinPackedMatrix.hpp:927
CoinPackedMatrix::CoinPackedMatrix
CoinPackedMatrix(const CoinPackedMatrix &m, int extraForMajor, int extraElements, bool reverseOrdering=false)
Copy constructor with fine tuning.
CoinPackedMatrix::rightAppendPackedMatrix
void rightAppendPackedMatrix(const CoinPackedMatrix &matrix)
Append the argument to the "right" of the current matrix.
CoinPackedMatrix::colOrdered_
bool colOrdered_
A flag indicating whether the matrix is column or row major ordered.
Definition: CoinPackedMatrix.hpp:900
CoinPackedMatrix::setExtraGap
void setExtraGap(const double newGap)
Set the extra gap to be allocated to the specified value.
CoinPackedMatrix::reserve
void reserve(const int newMaxMajorDim, const CoinBigIndex newMaxSize, bool create=false)
Reserve sufficient space for appending major-ordered vectors.
CoinPackedMatrix::getVectorSize
int getVectorSize(const int i) const
The length of i'th vector.
Definition: CoinPackedMatrix.hpp:181
CoinPackedMatrix::submatrixOfWithDuplicates
void submatrixOfWithDuplicates(const CoinPackedMatrix &matrix, const int numMajor, const int *indMajor)
Extract a submatrix from matrix.
CoinPackedMatrix::index_
int * index_
List of nonzero element minor-dimension indices.
Definition: CoinPackedMatrix.hpp:916
CoinPackedMatrix::copyOf
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.
CoinPackedMatrix::times
void times(const CoinPackedVectorBase &x, double *y) const
Return A * x in y.
CoinPackedMatrix::setExtraMajor
void setExtraMajor(const double newMajor)
Set the extra major to be allocated to the specified value.
CoinPackedMatrix::modifyCoefficient
void modifyCoefficient(int row, int column, double newElement, bool keepZero=false)
Modify one element of packed matrix.
CoinPackedMatrix::majorDim_
int majorDim_
number of vectors in matrix
Definition: CoinPackedMatrix.hpp:923
CoinPackedMatrix::appendMinorFast
void appendMinorFast(const int number, const CoinBigIndex *starts, const int *index, const double *element)
Append a set of rows (columns) to the end of a column (row) ordered matrix.
CoinPackedMatrix::majorAppendSameOrdered
void majorAppendSameOrdered(const CoinPackedMatrix &matrix)
Append the columns of the argument to the right end of this matrix.
CoinPackedMatrix::start_
CoinBigIndex * start_
Starting positions of major-dimension vectors.
Definition: CoinPackedMatrix.hpp:918
CoinPackedMatrix::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)
CoinPackedMatrix::appendMajorVector
void appendMajorVector(const int vecsize, const int *vecind, const double *vecelem)
Append a major-dimension vector to the end of the matrix.
CoinPackedMatrix::appendRow
void appendRow(const CoinPackedVectorBase &vec)
Append a row to the end of the matrix.
CoinPackedMatrix::nullLengthArray
void nullLengthArray()
NULLify length array.
Definition: CoinPackedMatrix.hpp:741
CoinTypes.hpp
CoinPackedMatrix::gutsOfCopyOfNoGaps
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.
CoinPackedMatrix::maxSize_
CoinBigIndex maxSize_
max space allocated for entries
Definition: CoinPackedMatrix.hpp:932
CoinPackedMatrix::element_
double * element_
List of nonzero element values.
Definition: CoinPackedMatrix.hpp:913
CoinPackedMatrix::cleanMatrix
int cleanMatrix(double threshold=1.0e-20)
Really clean up matrix.
CoinPackedMatrix::getNumElements
CoinBigIndex getNumElements() const
Number of entries in the packed matrix.
Definition: CoinPackedMatrix.hpp:107
CoinPackedMatrix::nullIndexArray
void nullIndexArray()
NULLify index array.
Definition: CoinPackedMatrix.hpp:747
CoinPackedMatrix::transpose
void transpose()
Transpose the matrix.
CoinPackedMatrix::countOrthoLength
int * countOrthoLength() const
Count the number of entries in every minor-dimension vector and return an array containing these leng...
CoinPackedMatrix::transposeTimes
void transposeTimes(const CoinPackedVectorBase &x, double *y) const
Return x * A in y.
CoinPackedMatrix::getNumRows
int getNumRows() const
Number of rows.
Definition: CoinPackedMatrix.hpp:114
CoinPackedMatrix::timesMajor
void timesMajor(const CoinPackedVectorBase &x, double *y) const
Return A * x (multiplied from the "right" direction) in y.
CoinPackedMatrix::resizeForAddingMajorVectors
void resizeForAddingMajorVectors(const int numVec, const int *lengthVec)
CoinPackedMatrix::minorDim_
int minorDim_
size of other dimension
Definition: CoinPackedMatrix.hpp:925
CoinPackedMatrix::CoinPackedMatrix
CoinPackedMatrix(const CoinPackedMatrix &wholeModel, int numberRows, const int *whichRows, int numberColumns, const int *whichColumns)
Subset constructor (without gaps).
CoinPackedMatrix::getElements
const double * getElements() const
A vector containing the elements in the packed matrix.
Definition: CoinPackedMatrix.hpp:124
CoinPackedMatrix::getMutableVectorLengths
int * getMutableVectorLengths() const
The lengths of the major-dimension vectors.
Definition: CoinPackedMatrix.hpp:721
CoinPackedMatrix::appendMinorVector
void appendMinorVector(const int vecsize, const int *vecind, const double *vecelem)
Append a minor-dimension vector to the end of the matrix.
CoinPackedMatrix::dumpMatrix
void dumpMatrix(const char *fname=NULL) const
Dump the matrix on stdout.
CoinPackedMatrix::length_
int * length_
Lengths of major-dimension vectors.
Definition: CoinPackedMatrix.hpp:920
CoinPackedMatrix::submatrixOf
void submatrixOf(const CoinPackedMatrix &matrix, const int numMajor, const int *indMajor)
Extract a submatrix from matrix.
CoinPackedMatrix::operator=
CoinPackedMatrix & operator=(const CoinPackedMatrix &rhs)
Assignment operator.
CoinPackedMatrix::extraMajor_
double extraMajor_
his much times more space should be allocated for major-dimension vectors when the matrix is resized.
Definition: CoinPackedMatrix.hpp:909
CoinPackedMatrix::getMutableVectorStarts
CoinBigIndex * getMutableVectorStarts() const
The positions where the major-dimension vectors start in element_ and index_.
Definition: CoinPackedMatrix.hpp:719
CoinPackedMatrix::isEquivalent
bool isEquivalent(const CoinPackedMatrix &rhs) const
Test for equivalence.
CoinPackedMatrix::nullStartArray
void nullStartArray()
NULLify start array.
Definition: CoinPackedMatrix.hpp:735
CoinPackedMatrix::getMutableIndices
int * getMutableIndices() const
A vector containing the minor indices of the elements in the packed matrix.
Definition: CoinPackedMatrix.hpp:715
CoinPackedMatrix::getCoefficient
double getCoefficient(int row, int column) const
Return one element of packed matrix.
CoinPackedMatrix::getLastStart
CoinBigIndex getLastStart() const
Definition: CoinPackedMatrix.hpp:890
CoinPackedMatrix::getSizeVectorStarts
int getSizeVectorStarts() const
The size of the vectorStarts array.
Definition: CoinPackedMatrix.hpp:140
CoinPackedMatrix::getExtraMajor
double getExtraMajor() const
Return the current setting of the extra major.
Definition: CoinPackedMatrix.hpp:91
CoinPackedMatrix::setDimensions
void setDimensions(int numrows, int numcols)
Set the dimensions of the matrix.
CoinPackedMatrix::reverseOrderedCopyOf
void reverseOrderedCopyOf(const CoinPackedMatrix &rhs)
Make a reverse-ordered copy.
CoinPackedMatrix::clear
void clear()
Clear the data, but do not free any arrays.
CoinPackedMatrix::transposeTimes
void transposeTimes(const double *x, double *y) const
Return x * A in y.
CoinPackedMatrix::compress
int compress(double threshold)
Eliminate all elements in matrix whose absolute value is less than threshold.
CoinPackedMatrix::maxMajorDim_
int maxMajorDim_
max space allocated for major-dimension
Definition: CoinPackedMatrix.hpp:930
CoinPackedMatrix::getVectorLast
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.
Definition: CoinPackedMatrix.hpp:173
CoinPackedMatrix::gutsOfDestructor
void gutsOfDestructor()
CoinPackedMatrix::deleteMinorVectors
void deleteMinorVectors(const int numDel, const int *indDel)
Delete the minor-dimension vectors whose indices are listed in indDel.
CoinPackedMatrix::printMatrixElement
void printMatrixElement(const int row_val, const int col_val) const
Print a single matrix element.
CoinPackedMatrix::minorAppendSameOrdered
void minorAppendSameOrdered(const CoinPackedMatrix &matrix)
Append the columns of the argument to the bottom end of this matrix.
CoinPackedMatrix::getVectorStarts
const CoinBigIndex * getVectorStarts() const
The positions where the major-dimension vectors start in elements and indices.
Definition: CoinPackedMatrix.hpp:154
CoinPackedMatrix::getMutableElements
double * getMutableElements() const
A vector containing the elements in the packed matrix.
Definition: CoinPackedMatrix.hpp:709
CoinPackedMatrix::getIndices
const int * getIndices() const
A vector containing the minor indices of the elements in the packed matrix.
Definition: CoinPackedMatrix.hpp:134
CoinPackedMatrix::~CoinPackedMatrix
virtual ~CoinPackedMatrix()
Destructor.
CoinPackedMatrix::setNumElements
void setNumElements(CoinBigIndex value)
Change the size of the bulk store after modifying - be careful.
Definition: CoinPackedMatrix.hpp:723
CoinPackedMatrix::getVectorFirst
CoinBigIndex getVectorFirst(const int i) const
The position of the first element in the i'th major-dimension vector.
Definition: CoinPackedMatrix.hpp:164
CoinPackedMatrix::getVectorLengths
const int * getVectorLengths() const
The lengths of the major-dimension vectors.
Definition: CoinPackedMatrix.hpp:160
CoinPackedMatrix::appendMinorVectors
void appendMinorVectors(const int numvecs, const CoinPackedVectorBase *const *vecs)
Append several minor-dimension vectors to the end of the matrix.
CoinPackedMatrix::isEquivalent2
bool isEquivalent2(const CoinPackedMatrix &rhs) const
Test for equivalence and report differences.
CoinError.hpp
CoinPackedMatrix::appendRows
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.
CoinPackedMatrix::getVector
const CoinShallowPackedVector getVector(int i) const
Return the i'th vector in matrix.
Definition: CoinPackedMatrix.hpp:190
CoinPackedMatrix::getSizeVectorLengths
int getSizeVectorLengths() const
The size of the vectorLengths array.
Definition: CoinPackedMatrix.hpp:147
CoinPackedMatrix::CoinPackedMatrix
CoinPackedMatrix(const CoinPackedMatrix &m)
Copy constructor.
CoinPackedMatrix::minorAppendOrthoOrdered
void minorAppendOrthoOrdered(const CoinPackedMatrix &matrix)
Append the rows of the argument to the bottom end of this matrix.
CoinPackedMatrix::deleteRows
void deleteRows(const int numDel, const int *indDel)
Delete the rows whose indices are listed in indDel.
CoinPackedMatrix::appendCol
void appendCol(const CoinPackedVectorBase &vec)
Append a column to the end of the matrix.
CoinPackedMatrix::times
void times(const double *x, double *y) const
Return A * x in y.
CoinPackedMatrix::countOrthoLength
void countOrthoLength(int *counts) const
Count the number of entries in every minor-dimension vector and fill in an array containing these len...
CoinPackedMatrix::hasGaps
bool hasGaps() const
Whether the packed matrix has gaps or not.
Definition: CoinPackedMatrix.hpp:104
CoinPackedVectorBase
Abstract base class for various sparse vectors.
Definition: CoinPackedVectorBase.hpp:23
CoinPackedMatrix::bottomAppendPackedMatrix
void bottomAppendPackedMatrix(const CoinPackedMatrix &matrix)
Append the argument to the "bottom" of the current matrix.
CoinPackedMatrix::timesMinor
void timesMinor(const CoinPackedVectorBase &x, double *y) const
Return A * x (multiplied from the "right" direction) in y.
CoinPackedMatrix::appendCols
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.
CoinPackedMatrix::setMajorDim
void setMajorDim(int value)
Set major dimension.
Definition: CoinPackedMatrix.hpp:501
CoinPackedMatrix::CoinPackedMatrix
CoinPackedMatrix(const bool colordered, const double extraMajor, const double extraGap)
A constructor where the ordering and the gaps are specified.
CoinPackedMatrix::getMaxMajorDim
int getMaxMajorDim() const
Current maximum for major dimension.
Definition: CoinPackedMatrix.hpp:511
CoinPackedMatrix::getMinorDim
int getMinorDim() const
Minor dimension.
Definition: CoinPackedMatrix.hpp:504
CoinPackedMatrix
Sparse Matrix Base Class.
Definition: CoinPackedMatrix.hpp:79
CoinPackedMatrix::getMajorDim
int getMajorDim() const
Major dimension.
Definition: CoinPackedMatrix.hpp:498
CoinPackedMatrix::orderMatrix
void orderMatrix()
Sort all columns so indices are increasing.in each column.
CoinPackedMatrix::gutsOfCopyOf
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)
CoinPackedMatrix::setMinorDim
void setMinorDim(int value)
Set minor dimension.
Definition: CoinPackedMatrix.hpp:507
CoinPackedMatrix::nullElementArray
void nullElementArray()
NULLify element array.
Definition: CoinPackedMatrix.hpp:729
CoinPackedMatrix::appendMinor
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 a column (row) ordered matrix.
CoinPackedMatrix::gutsOfOpEqual
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)
CoinPackedMatrix::timesMajor
void timesMajor(const double *x, double *y) const
Return A * x (multiplied from the "right" direction) in y.
CoinPackedMatrix::appendRow
void appendRow(const int vecsize, const int *vecind, const double *vecelem)
Append a row to the end of the matrix.
CoinPackedMatrix::replaceVector
void replaceVector(const int index, const int numReplace, const double *newElements)
Replace the elements of a vector.
CoinPackedMatrix::getExtraGap
double getExtraGap() const
Return the current setting of the extra gap.
Definition: CoinPackedMatrix.hpp:89
CoinPackedMatrix::appendMajorVectors
void appendMajorVectors(const int numvecs, const CoinPackedVectorBase *const *vecs)
Append several major-dimensonvectors to the end of the matrix.
CoinPackedMatrixUnitTest
void CoinPackedMatrixUnitTest()
Test the methods in the CoinPackedMatrix class.
CoinPackedMatrix::appendMajor
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 a row (colum) ordered matrix.
CoinPackedMatrix::getMajorIndices
int * getMajorIndices() const
Returns an array containing major indices.
CoinPackedMatrix::reverseOrdering
void reverseOrdering()
Reverse the ordering of the packed matrix.
CoinPackedMatrix::appendMajorVector
void appendMajorVector(const CoinPackedVectorBase &vec)
Append a major-dimension vector to the end of the matrix.
CoinPackedMatrix::extraGap_
double extraGap_
This much times more space should be allocated for each major-dimension vector (with respect to the n...
Definition: CoinPackedMatrix.hpp:905
CoinPackedMatrix::assignMatrix
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.
CoinPackedMatrix::appendMinorVector
void appendMinorVector(const CoinPackedVectorBase &vec)
Append a minor-dimension vector to the end of the matrix.
CoinError
Error Class thrown by an exception.
Definition: CoinError.hpp:42
CoinShallowPackedVector.hpp
CoinPackedMatrix::verifyMtx
int verifyMtx(int verbosity=1, bool zeroesAreError=false) const
Scan the matrix for anomalies.
CoinPackedVectorBase::isEquivalent
bool isEquivalent(const CoinPackedVectorBase &rhs, const FloatEqual &eq) const
equivalent - If shallow packed vector A & B are equivalent, then they are still equivalent no matter ...
Definition: CoinPackedVectorBase.hpp:140
CoinPackedMatrix::appendCols
void appendCols(const int numcols, const CoinPackedVectorBase *const *cols)
Append a set of columns to the end of the matrix.
CoinPackedMatrix::CoinPackedMatrix
CoinPackedMatrix(const bool colordered, const int *rowIndices, const int *colIndices, const double *elements, CoinBigIndex numels)
Create packed matrix from triples.
CoinPackedMatrix::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)
CoinRelFltEq
Equality to a scaled tolerance.
Definition: CoinFloatEqual.hpp:111
CoinPackedMatrix::CoinPackedMatrixUnitTest
friend void CoinPackedMatrixUnitTest()
Test the methods in the CoinPackedMatrix class.
CoinPackedMatrix::appendCol
void appendCol(const int vecsize, const int *vecind, const double *vecelem)
Append a column to the end of the matrix.
CoinPackedMatrix::deleteMajorVectors
void deleteMajorVectors(const int numDel, const int *indDel)
Delete the major-dimension vectors whose indices are listed in indDel.
CoinPackedMatrix::copyOf
void copyOf(const CoinPackedMatrix &rhs)
Copy method.
CoinPackedMatrix::isColOrdered
bool isColOrdered() const
Whether the packed matrix is column major ordered or not.
Definition: CoinPackedMatrix.hpp:101
CoinPackedMatrix::removeGaps
void removeGaps(double removeValue=-1.0)
Remove the gaps from the matrix if there were any Can also remove small elements fabs() <= removeValu...
CoinPackedMatrix::timesMinor
void timesMinor(const double *x, double *y) const
Return A * x (multiplied from the "right" direction) in y.
CoinPackedMatrix::majorAppendOrthoOrdered
void majorAppendOrthoOrdered(const CoinPackedMatrix &matrix)
Append the rows of the argument to the right end of this matrix.
CoinPackedVectorBase.hpp
CoinShallowPackedVector
Shallow Sparse Vector.
Definition: CoinShallowPackedVector.hpp:74
CoinPackedMatrix::appendRows
void appendRows(const int numrows, const CoinPackedVectorBase *const *rows)
Append a set of rows to the end of the matrix.
CoinPackedMatrix::CoinPackedMatrix
CoinPackedMatrix()
Default Constructor creates an empty column ordered packed matrix.
CoinPackedMatrix::resizeForAddingMinorVectors
void resizeForAddingMinorVectors(const int *addedEntries)
CoinPackedMatrix::eliminateDuplicates
int eliminateDuplicates(double threshold)
Eliminate all duplicate AND small elements in matrix The column starts are not affected.
CoinBigIndex
int CoinBigIndex
Definition: Coin_C_defines.h:105
CoinPackedMatrix::deleteCols
void deleteCols(const int numDel, const int *indDel)
Delete the columns whose indices are listed in indDel.
CoinPackedMatrix::swap
void swap(CoinPackedMatrix &matrix)
Swap the content of two packed matrices.
CoinPackedMatrix::getNumCols
int getNumCols() const
Number of columns.
Definition: CoinPackedMatrix.hpp:110
CoinPackedMatrix::isEquivalent
bool isEquivalent(const CoinPackedMatrix &rhs, const FloatEqual &eq) const
Test for equivalence.
Definition: CoinPackedMatrix.hpp:656