CoinUtils  2.9.15
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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