CoinUtils  2.11.9
CoinPackedMatrix.hpp
Go to the documentation of this file.
1 /* $Id$ */
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  //---------------------------------------------------------------------------
87  inline double getExtraGap() const { return extraGap_; }
89  inline double getExtraMajor() const { return extraMajor_; }
90 
93  void reserve(const int newMaxMajorDim, const CoinBigIndex newMaxSize,
94  bool create = false);
96  void clear();
97 
99  inline bool isColOrdered() const { return colOrdered_; }
100 
102  inline bool hasGaps() const { return (size_ < start_[majorDim_]); }
103 
105  inline CoinBigIndex getNumElements() const { return size_; }
106 
108  inline int getNumCols() const
109  {
110  return colOrdered_ ? majorDim_ : minorDim_;
111  }
112 
114  inline int getNumRows() const
115  {
116  return colOrdered_ ? minorDim_ : majorDim_;
117  }
118 
126  inline const double *getElements() const { return element_; }
127 
136  inline const int *getIndices() const { return index_; }
137 
142  inline int getSizeVectorStarts() const
143  {
144  return ((majorDim_ > 0) ? (majorDim_ + 1) : (0));
145  }
146 
151  inline int getSizeVectorLengths() const { return majorDim_; }
152 
158  inline const CoinBigIndex *getVectorStarts() const { return start_; }
159 
164  inline const int *getVectorLengths() const { return length_; }
165 
168  CoinBigIndex getVectorFirst(const int i) const
169  {
170 #ifndef COIN_FAST_CODE
171  if (i < 0 || i >= majorDim_)
172  throw CoinError("bad index", "vectorFirst", "CoinPackedMatrix");
173 #endif
174  return start_[i];
175  }
178  CoinBigIndex getVectorLast(const int i) const
179  {
180 #ifndef COIN_FAST_CODE
181  if (i < 0 || i >= majorDim_)
182  throw CoinError("bad index", "vectorLast", "CoinPackedMatrix");
183 #endif
184  return start_[i] + length_[i];
185  }
187  inline int getVectorSize(const int i) const
188  {
189 #ifndef COIN_FAST_CODE
190  if (i < 0 || i >= majorDim_)
191  throw CoinError("bad index", "vectorSize", "CoinPackedMatrix");
192 #endif
193  return length_[i];
194  }
195 #ifndef CLP_NO_VECTOR
196 
198  {
199 #ifndef COIN_FAST_CODE
200  if (i < 0 || i >= majorDim_)
201  throw CoinError("bad index", "vector", "CoinPackedMatrix");
202 #endif
204  index_ + start_[i],
205  element_ + start_[i],
206  false);
207  }
208 #endif
209 
219  int *getMajorIndices() const;
221 
222  //---------------------------------------------------------------------------
233  void setDimensions(int numrows, int numcols);
234 
236  void setExtraGap(const double newGap);
238  void setExtraMajor(const double newMajor);
239 #ifndef CLP_NO_VECTOR
240 
246  void appendCol(const CoinPackedVectorBase &vec);
247 #endif
248 
254  void appendCol(const int vecsize,
255  const int *vecind, const double *vecelem);
256 #ifndef CLP_NO_VECTOR
257 
263  void appendCols(const int numcols,
264  const CoinPackedVectorBase *const *cols);
265 #endif
266 
271  int appendCols(const int numcols,
272  const CoinBigIndex *columnStarts, const int *row,
273  const double *element, int numberRows = -1);
274 #ifndef CLP_NO_VECTOR
275 
281  void appendRow(const CoinPackedVectorBase &vec);
282 #endif
283 
289  void appendRow(const int vecsize,
290  const int *vecind, const double *vecelem);
291 #ifndef CLP_NO_VECTOR
292 
298  void appendRows(const int numrows,
299  const CoinPackedVectorBase *const *rows);
300 #endif
301 
306  int appendRows(const int numrows,
307  const CoinBigIndex *rowStarts, const int *column,
308  const double *element, int numberColumns = -1);
309 
314  void rightAppendPackedMatrix(const CoinPackedMatrix &matrix);
319  void bottomAppendPackedMatrix(const CoinPackedMatrix &matrix);
320 
322  void deleteCols(const int numDel, const int *indDel);
324  void deleteRows(const int numDel, const int *indDel);
325 
329  void replaceVector(const int index,
330  const int numReplace, const double *newElements);
335  void modifyCoefficient(int row, int column, double newElement,
336  bool keepZero = false);
340  double getCoefficient(int row, int column) const;
341 
347  CoinBigIndex compress(double threshold);
352  CoinBigIndex eliminateDuplicates(double threshold);
354  void orderMatrix();
362  CoinBigIndex cleanMatrix(double threshold = 1.0e-20);
364 
365  //---------------------------------------------------------------------------
370  void removeGaps(double removeValue = -1.0);
371 
375  void submatrixOf(const CoinPackedMatrix &matrix,
376  const int numMajor, const int *indMajor);
380  void submatrixOfWithDuplicates(const CoinPackedMatrix &matrix,
381  const int numMajor, const int *indMajor);
382 #if 0
383 
386  void submatrixOf(const CoinPackedMatrix& matrix,
387  const int numMajor, const int * indMajor,
388  const int numMinor, const int * indMinor);
389 #endif
390 
393  void copyOf(const CoinPackedMatrix &rhs);
397  void copyOf(const bool colordered,
398  const int minor, const int major, const CoinBigIndex numels,
399  const double *elem, const int *ind,
400  const CoinBigIndex *start, const int *len,
401  const double extraMajor = 0.0, const double extraGap = 0.0);
405  void copyReuseArrays(const CoinPackedMatrix &rhs);
406 
414  void reverseOrderedCopyOf(const CoinPackedMatrix &rhs);
415 
424  void assignMatrix(const bool colordered,
425  const int minor, const int major,
426  const CoinBigIndex numels,
427  double *&elem, int *&ind,
428  CoinBigIndex *&start, int *&len,
429  const int maxmajor = -1, const CoinBigIndex maxsize = -1);
430 
434 
441  void reverseOrdering();
442 
452  void transpose();
453 
455  void swap(CoinPackedMatrix &matrix);
456 
458 
459  //---------------------------------------------------------------------------
465  void times(const double *x, double *y) const;
466 #ifndef CLP_NO_VECTOR
467 
469  void times(const CoinPackedVectorBase &x, double *y) const;
470 #endif
471 
474  void transposeTimes(const double *x, double *y) const;
475 #ifndef CLP_NO_VECTOR
476 
478  void transposeTimes(const CoinPackedVectorBase &x, double *y) const;
479 #endif
480 
481 
482  //---------------------------------------------------------------------------
490 
491  //-------------------------------------------------------------------------
498  int *countOrthoLength() const;
501  void countOrthoLength(int *counts) const;
504  inline int getMajorDim() const { return majorDim_; }
507  inline void setMajorDim(int value) { majorDim_ = value; }
510  inline int getMinorDim() const { return minorDim_; }
513  inline void setMinorDim(int value) { minorDim_ = value; }
517  inline int getMaxMajorDim() const { return maxMajorDim_; }
518 
521  void dumpMatrix(const char *fname = NULL) const;
522 
524  void printMatrixElement(const int row_val, const int col_val) const;
526 
527  //-------------------------------------------------------------------------
537 #ifndef CLP_NO_VECTOR
538 
539  void appendMajorVector(const CoinPackedVectorBase &vec);
540 #endif
541 
542  void appendMajorVector(const int vecsize, const int *vecind,
543  const double *vecelem);
544 #ifndef CLP_NO_VECTOR
545 
546  void appendMajorVectors(const int numvecs,
547  const CoinPackedVectorBase *const *vecs);
548 
550  void appendMinorVector(const CoinPackedVectorBase &vec);
551 #endif
552 
553  void appendMinorVector(const int vecsize, const int *vecind,
554  const double *vecelem);
555 #ifndef CLP_NO_VECTOR
556 
557  void appendMinorVectors(const int numvecs,
558  const CoinPackedVectorBase *const *vecs);
559 #endif
560 
572  void appendMinorFast(const int number,
573  const CoinBigIndex *starts, const int *index,
574  const double *element);
576 
577  //-------------------------------------------------------------------------
591  void majorAppendSameOrdered(const CoinPackedMatrix &matrix);
596  void minorAppendSameOrdered(const CoinPackedMatrix &matrix);
602  void majorAppendOrthoOrdered(const CoinPackedMatrix &matrix);
608  void minorAppendOrthoOrdered(const CoinPackedMatrix &matrix);
610 
611  //-----------------------------------------------------------------------
616  void deleteMajorVectors(const int numDel, const int *indDel);
619  void deleteMinorVectors(const int numDel, const int *indDel);
621 
622  //-----------------------------------------------------------------------
629  void timesMajor(const double *x, double *y) const;
630 #ifndef CLP_NO_VECTOR
631 
634  void timesMajor(const CoinPackedVectorBase &x, double *y) const;
635 #endif
636 
640  void timesMinor(const double *x, double *y) const;
641 #ifndef CLP_NO_VECTOR
642 
645  void timesMinor(const CoinPackedVectorBase &x, double *y) const;
646 #endif
647 
648 
649 
650  //--------------------------------------------------------------------------
653 #ifndef CLP_NO_VECTOR
654 
661  template < class FloatEqual >
662  bool
663  isEquivalent(const CoinPackedMatrix &rhs, const FloatEqual &eq) const
664  {
665  // Both must be column order or both row ordered and must be of same size
666  if ((isColOrdered() ^ rhs.isColOrdered()) || (getNumCols() != rhs.getNumCols()) || (getNumRows() != rhs.getNumRows()) || (getNumElements() != rhs.getNumElements()))
667  return false;
668 
669  for (int i = getMajorDim() - 1; i >= 0; --i) {
671  CoinShallowPackedVector rhsPv = rhs.getVector(i);
672  if (!pv.isEquivalent(rhsPv, eq))
673  return false;
674  }
675  return true;
676  }
677 
684  bool isEquivalent2(const CoinPackedMatrix &rhs) const;
685 #else
686 
694  bool isEquivalent(const CoinPackedMatrix &rhs, const CoinRelFltEq &eq) const;
695 #endif
696 
700  bool isEquivalent(const CoinPackedMatrix &rhs) const;
702 
703  //--------------------------------------------------------------------------
713  inline double *getMutableElements() const { return element_; }
719  inline int *getMutableIndices() const { return index_; }
720 
723  inline CoinBigIndex *getMutableVectorStarts() const { return start_; }
725  inline int *getMutableVectorLengths() const { return length_; }
727  inline void setNumElements(CoinBigIndex value)
728  {
729  size_ = value;
730  }
735  inline void nullElementArray() { element_ = NULL; }
736 
741  inline void nullStartArray() { start_ = NULL; }
742 
747  inline void nullLengthArray() { length_ = NULL; }
748 
753  inline void nullIndexArray() { index_ = NULL; }
755 
756  //--------------------------------------------------------------------------
761 
763  CoinPackedMatrix(const bool colordered,
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  const double extraMajor, const double extraGap);
771 
772  CoinPackedMatrix(const bool colordered,
773  const int minor, const int major, const CoinBigIndex numels,
774  const double *elem, const int *ind,
775  const CoinBigIndex *start, const int *len);
776 
787  CoinPackedMatrix(const bool colordered,
788  const int *rowIndices,
789  const int *colIndices,
790  const double *elements,
791  CoinBigIndex numels);
792 
795 
811  int extraForMajor, int extraElements,
812  bool reverseOrdering = false);
813 
816  CoinPackedMatrix(const CoinPackedMatrix &wholeModel,
817  int numberRows, const int *whichRows,
818  int numberColumns, const int *whichColumns);
819 
821  virtual ~CoinPackedMatrix();
823 
847  int verifyMtx(int verbosity = 1, bool zeroesAreError = false) const;
849 
850  //--------------------------------------------------------------------------
851 protected:
852  void gutsOfDestructor();
853  void gutsOfCopyOf(const bool colordered,
854  const int minor, const int major, const CoinBigIndex numels,
855  const double *elem, const int *ind,
856  const CoinBigIndex *start, const int *len,
857  const double extraMajor = 0.0, const double extraGap = 0.0);
859  void gutsOfCopyOfNoGaps(const bool colordered,
860  const int minor, const int major,
861  const double *elem, const int *ind,
862  const CoinBigIndex *start);
863  void gutsOfOpEqual(const bool colordered,
864  const int minor, const int major, const CoinBigIndex numels,
865  const double *elem, const int *ind,
866  const CoinBigIndex *start, const int *len);
867  void resizeForAddingMajorVectors(const int numVec, const int *lengthVec);
868  void resizeForAddingMinorVectors(const int *addedEntries);
869 
879  int appendMajor(const int number,
880  const CoinBigIndex *starts, const int *index,
881  const double *element, int numberOther = -1);
891  int appendMinor(const int number,
892  const CoinBigIndex *starts, const int *index,
893  const double *element, int numberOther = -1);
894 
895 private:
896  inline CoinBigIndex getLastStart() const
897  {
898  return majorDim_ == 0 ? 0 : start_[majorDim_];
899  }
900 
901  //--------------------------------------------------------------------------
902 protected:
912  double extraGap_;
916  double extraMajor_;
917 
920  double *element_;
923  int *index_;
927  int *length_;
928 
935 
941 };
942 
943 //#############################################################################
952 
953 #endif
954 
955 /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
956 */
CoinPackedVectorBase.hpp
CoinPackedMatrix::copyReuseArrays
void copyReuseArrays(const CoinPackedMatrix &rhs)
Copy method.
CoinPackedMatrix::size_
CoinBigIndex size_
the number of nonzero entries
Definition: CoinPackedMatrix.hpp:934
CoinPackedMatrix::element_
double * element_
List of nonzero element values.
Definition: CoinPackedMatrix.hpp:920
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:907
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:187
CoinPackedMatrix::submatrixOfWithDuplicates
void submatrixOfWithDuplicates(const CoinPackedMatrix &matrix, const int numMajor, const int *indMajor)
Extract a submatrix from matrix.
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:930
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::start_
CoinBigIndex * start_
Starting positions of major-dimension vectors.
Definition: CoinPackedMatrix.hpp:925
CoinPackedMatrix::majorAppendSameOrdered
void majorAppendSameOrdered(const CoinPackedMatrix &matrix)
Append the columns of the argument to the right end of this matrix.
CoinTypes.hpp
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:747
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:939
CoinPackedMatrix::index_
int * index_
List of nonzero element minor-dimension indices.
Definition: CoinPackedMatrix.hpp:923
CoinPackedMatrix::getNumElements
CoinBigIndex getNumElements() const
Number of entries in the packed matrix.
Definition: CoinPackedMatrix.hpp:105
CoinPackedMatrix::nullIndexArray
void nullIndexArray()
NULLify index array.
Definition: CoinPackedMatrix.hpp:753
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::getNumRows
int getNumRows() const
Number of rows.
Definition: CoinPackedMatrix.hpp:114
CoinPackedMatrix::resizeForAddingMajorVectors
void resizeForAddingMajorVectors(const int numVec, const int *lengthVec)
CoinPackedMatrix::minorDim_
int minorDim_
size of other dimension
Definition: CoinPackedMatrix.hpp:932
CoinPackedMatrix::getElements
const double * getElements() const
A vector containing the elements in the packed matrix.
Definition: CoinPackedMatrix.hpp:126
CoinPackedMatrix::getMutableVectorLengths
int * getMutableVectorLengths() const
The lengths of the major-dimension vectors.
Definition: CoinPackedMatrix.hpp:725
CoinPackedMatrix::dumpMatrix
void dumpMatrix(const char *fname=NULL) const
Dump the matrix on stdout.
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:916
CoinPackedMatrix::getMutableVectorStarts
CoinBigIndex * getMutableVectorStarts() const
The positions where the major-dimension vectors start in element_ and index_.
Definition: CoinPackedMatrix.hpp:723
CoinPackedMatrix::nullStartArray
void nullStartArray()
NULLify start array.
Definition: CoinPackedMatrix.hpp:741
CoinPackedMatrix::getMutableIndices
int * getMutableIndices() const
A vector containing the minor indices of the elements in the packed matrix.
Definition: CoinPackedMatrix.hpp:719
CoinPackedMatrix::getCoefficient
double getCoefficient(int row, int column) const
Return one element of packed matrix.
CoinPackedMatrix::getLastStart
CoinBigIndex getLastStart() const
Definition: CoinPackedMatrix.hpp:896
CoinPackedMatrix::getSizeVectorStarts
int getSizeVectorStarts() const
The size of the vectorStarts array.
Definition: CoinPackedMatrix.hpp:142
CoinPackedMatrix::getExtraMajor
double getExtraMajor() const
Return the current setting of the extra major.
Definition: CoinPackedMatrix.hpp:89
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::maxMajorDim_
int maxMajorDim_
max space allocated for major-dimension
Definition: CoinPackedMatrix.hpp:937
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:178
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.
CoinPackedMatrixUnitTest
void CoinPackedMatrixUnitTest()
Test the methods in the CoinPackedMatrix class.
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:158
CoinPackedMatrix::getMutableElements
double * getMutableElements() const
A vector containing the elements in the packed matrix.
Definition: CoinPackedMatrix.hpp:713
CoinPackedMatrix::getIndices
const int * getIndices() const
A vector containing the minor indices of the elements in the packed matrix.
Definition: CoinPackedMatrix.hpp:136
CoinPackedMatrix::eliminateDuplicates
CoinBigIndex eliminateDuplicates(double threshold)
Eliminate all duplicate AND small elements in matrix The column starts are not affected.
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:727
CoinPackedMatrix::getVectorFirst
CoinBigIndex getVectorFirst(const int i) const
The position of the first element in the i'th major-dimension vector.
Definition: CoinPackedMatrix.hpp:168
CoinPackedMatrix::getVectorLengths
const int * getVectorLengths() const
The lengths of the major-dimension vectors.
Definition: CoinPackedMatrix.hpp:164
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.
CoinPackedMatrix::getVector
const CoinShallowPackedVector getVector(int i) const
Return the i'th vector in matrix.
Definition: CoinPackedMatrix.hpp:197
CoinPackedMatrix::compress
CoinBigIndex compress(double threshold)
Eliminate all elements in matrix whose absolute value is less than threshold.
CoinBigIndex
int CoinBigIndex
Definition: Coin_C_defines.h:136
CoinPackedMatrix::getSizeVectorLengths
int getSizeVectorLengths() const
The size of the vectorLengths array.
Definition: CoinPackedMatrix.hpp:151
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::hasGaps
bool hasGaps() const
Whether the packed matrix has gaps or not.
Definition: CoinPackedMatrix.hpp:102
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::setMajorDim
void setMajorDim(int value)
Set major dimension.
Definition: CoinPackedMatrix.hpp:507
CoinPackedMatrix::getMaxMajorDim
int getMaxMajorDim() const
Current maximum for major dimension.
Definition: CoinPackedMatrix.hpp:517
CoinPackedMatrix::getMinorDim
int getMinorDim() const
Minor dimension.
Definition: CoinPackedMatrix.hpp:510
CoinPackedMatrix::cleanMatrix
CoinBigIndex cleanMatrix(double threshold=1.0e-20)
Really clean up matrix.
CoinPackedMatrix
Sparse Matrix Base Class.
Definition: CoinPackedMatrix.hpp:79
CoinPackedMatrix::getMajorDim
int getMajorDim() const
Major dimension.
Definition: CoinPackedMatrix.hpp:504
CoinPackedMatrix::orderMatrix
void orderMatrix()
Sort all columns so indices are increasing.in each column.
CoinPackedMatrix::length_
int * length_
Lengths of major-dimension vectors.
Definition: CoinPackedMatrix.hpp:927
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:513
CoinPackedMatrix::nullElementArray
void nullElementArray()
NULLify element array.
Definition: CoinPackedMatrix.hpp:735
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::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:87
CoinPackedMatrix::appendMajorVectors
void appendMajorVectors(const int numvecs, const CoinPackedVectorBase *const *vecs)
Append several major-dimensonvectors to the end of the matrix.
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:912
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
CoinPackedMatrix::verifyMtx
int verifyMtx(int verbosity=1, bool zeroesAreError=false) const
Scan the matrix for anomalies.
CoinShallowPackedVector.hpp
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:144
CoinPackedMatrix::appendCols
void appendCols(const int numcols, const CoinPackedVectorBase *const *cols)
Append a set of columns to the end of the matrix.
CoinRelFltEq
Equality to a scaled tolerance.
Definition: CoinFloatEqual.hpp:120
CoinPackedMatrix::CoinPackedMatrixUnitTest
friend void CoinPackedMatrixUnitTest()
Test the methods in the CoinPackedMatrix class.
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:99
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.
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)
CoinError.hpp
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:108
CoinPackedMatrix::isEquivalent
bool isEquivalent(const CoinPackedMatrix &rhs, const FloatEqual &eq) const
Test for equivalence.
Definition: CoinPackedMatrix.hpp:663