Cbc  2.9.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CoinIndexedVector.hpp
Go to the documentation of this file.
1 /* $Id: CoinIndexedVector.hpp 1767 2015-01-05 12:36:13Z forrest $ */
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 CoinIndexedVector_H
7 #define CoinIndexedVector_H
8 
9 #if defined(_MSC_VER)
10 // Turn off compiler warning about long names
11 # pragma warning(disable:4786)
12 #endif
13 
14 #include <map>
15 #include "CoinFinite.hpp"
16 #ifndef CLP_NO_VECTOR
17 #include "CoinPackedVectorBase.hpp"
18 #endif
19 #include "CoinSort.hpp"
20 #include "CoinHelperFunctions.hpp"
21 #include <cassert>
22 
23 #ifndef COIN_FLOAT
24 #define COIN_INDEXED_TINY_ELEMENT 1.0e-50
25 #define COIN_INDEXED_REALLY_TINY_ELEMENT 1.0e-100
26 #else
27 #define COIN_INDEXED_TINY_ELEMENT 1.0e-35
28 #define COIN_INDEXED_REALLY_TINY_ELEMENT 1.0e-39
29 #endif
30 
105  friend void CoinIndexedVectorUnitTest();
106 
107 public:
110  inline int getNumElements() const { return nElements_; }
113  inline const int * getIndices() const { return indices_; }
115  // ** No longer supported virtual const double * getElements() const ;
117  inline int * getIndices() { return indices_; }
121  inline double * denseVector() const { return elements_; }
123  inline void setDenseVector(double * array)
124  { elements_ = array;}
126  inline void setIndexVector(int * array)
127  { indices_ = array;}
130  double & operator[](int i) const;
131 
133 
134  //-------------------------------------------------------------------
135  // Set indices and elements
136  //-------------------------------------------------------------------
139  inline void setNumElements(int value) { nElements_ = value;
141  if (!nElements_) packedMode_=false;}
143  void clear();
145  void empty();
148 #ifndef CLP_NO_VECTOR
149 
152 #endif
153 
156  void copy(const CoinIndexedVector & rhs, double multiplier=1.0);
157 
160  void borrowVector(int size, int numberIndices, int* inds, double* elems);
161 
165  void returnVector();
166 
171  void setVector(int numberIndices, const int * inds, const double * elems);
172 
177  void setVector(int size, int numberIndices, const int * inds, const double * elems);
178 
180  void setConstant(int size, const int * inds, double elems);
181 
183  void setFull(int size, const double * elems);
184 
188  void setElement(int index, double element);
189 
191  void insert(int index, double element);
193  inline void quickInsert(int index, double element)
194  {
195  assert (!elements_[index]);
196  indices_[nElements_++] = index;
197  assert (nElements_<=capacity_);
198  elements_[index] = element;
199  }
202  void add(int index, double element);
206  inline void quickAdd(int index, double element)
207  {
208  if (elements_[index]) {
209  element += elements_[index];
210  if ((element > 0 ? element : -element) >= COIN_INDEXED_TINY_ELEMENT) {
211  elements_[index] = element;
212  } else {
213  elements_[index] = 1.0e-100;
214  }
215  } else if ((element > 0 ? element : -element) >= COIN_INDEXED_TINY_ELEMENT) {
216  indices_[nElements_++] = index;
217  assert (nElements_<=capacity_);
218  elements_[index] = element;
219  }
220  }
225  inline void quickAddNonZero(int index, double element)
226  {
227  assert (element);
228  if (elements_[index]) {
229  element += elements_[index];
230  if ((element > 0 ? element : -element) >= COIN_INDEXED_TINY_ELEMENT) {
231  elements_[index] = element;
232  } else {
233  elements_[index] = COIN_DBL_MIN;
234  }
235  } else {
236  indices_[nElements_++] = index;
237  assert (nElements_<=capacity_);
238  elements_[index] = element;
239  }
240  }
243  inline void zero(int index)
244  {
245  if (elements_[index])
246  elements_[index] = COIN_DBL_MIN;
247  }
250  int clean(double tolerance);
252  int cleanAndPack(double tolerance);
254  int cleanAndPackSafe(double tolerance);
256  inline void setPacked()
257  { packedMode_ = true;}
258 #ifndef NDEBUG
259  void checkClear();
262  void checkClean();
263 #else
264  inline void checkClear() {};
265  inline void checkClean() {};
266 #endif
267  int scan();
272  int scan(int start, int end);
275  int scan(double tolerance);
279  int scan(int start, int end, double tolerance);
281  int scanAndPack();
282  int scanAndPack(int start, int end);
283  int scanAndPack(double tolerance);
284  int scanAndPack(int start, int end, double tolerance);
286  void createPacked(int number, const int * indices,
287  const double * elements);
289  void createUnpacked(int number, const int * indices,
290  const double * elements);
292  void createOneUnpackedElement(int index, double element);
294  void expand();
295 #ifndef CLP_NO_VECTOR
296  void append(const CoinPackedVectorBase & caboose);
298 #endif
299  void append(const CoinIndexedVector & caboose);
302  void append(CoinIndexedVector & other,int adjustIndex,bool zapElements=false);
303 
305  void swap(int i, int j);
306 
308  void truncate(int newSize);
310  void print() const;
312 
314  void operator+=(double value);
317  void operator-=(double value);
319  void operator*=(double value);
321  void operator/=(double value);
323 
326 #ifndef CLP_NO_VECTOR
327 
329  bool operator==(const CoinPackedVectorBase & rhs) const;
331  bool operator!=(const CoinPackedVectorBase & rhs) const;
332 #endif
333 
335  bool operator==(const CoinIndexedVector & rhs) const;
337  bool operator!=(const CoinIndexedVector & rhs) const;
339  int isApproximatelyEqual(const CoinIndexedVector & rhs, double tolerance=1.0e-8) const;
341 
344  int getMaxIndex() const;
347  int getMinIndex() const;
349 
350 
354  void sort()
355  { std::sort(indices_,indices_+nElements_); }
356 
358  { std::sort(indices_,indices_+nElements_); }
359 
360  void sortDecrIndex();
361 
362  void sortIncrElement();
363 
364  void sortDecrElement();
365  void sortPacked();
366 
368 
369  //#############################################################################
370 
384  const CoinIndexedVector& op2);
385 
388  const CoinIndexedVector& op2);
389 
392  const CoinIndexedVector& op2);
393 
396  const CoinIndexedVector& op2);
398 void operator+=(const CoinIndexedVector& op2);
399 
401 void operator-=( const CoinIndexedVector& op2);
402 
404 void operator*=(const CoinIndexedVector& op2);
405 
407 void operator/=(const CoinIndexedVector& op2);
409 
416  void reserve(int n);
420  inline int capacity() const { return capacity_; }
421  inline void setCapacity(int value)
422  { capacity_ = value; }
424  inline void setPackedMode(bool yesNo)
425  { packedMode_=yesNo;}
427  inline bool packedMode() const
428  { return packedMode_;}
430 
436  CoinIndexedVector(int size, const int * inds, const double * elems);
438  CoinIndexedVector(int size, const int * inds, double element);
441  CoinIndexedVector(int size, const double * elements);
443  CoinIndexedVector(int size);
448 #ifndef CLP_NO_VECTOR
449 
451 #endif
452 
455 
456 private:
459  void gutsOfSetVector(int size,
461  const int * inds, const double * elems);
462  void gutsOfSetVector(int size, int numberIndices,
463  const int * inds, const double * elems);
464  void gutsOfSetPackedVector(int size, int numberIndices,
465  const int * inds, const double * elems);
467  void gutsOfSetConstant(int size,
468  const int * inds, double value);
470 
471 protected:
474  int * indices_;
477  double * elements_;
483  int offset_;
487 };
488 
489 //#############################################################################
495 void
514 
515 public:
518  inline int getSize() const
520  { return size_; }
522  inline int rawSize() const
523  { return size_; }
525  inline bool switchedOn() const
526  { return size_!=-1; }
528  inline int capacity() const
529  { return (size_>-2) ? size_ : (-size_)-2; }
531  inline void setCapacity()
532  { if (size_<=-2) size_ = (-size_)-2; }
534  inline const char * array() const
535  { return (size_>-2) ? array_ : NULL; }
537 
540  inline void setSize(int value)
542  { size_ = value; }
544  inline void switchOff()
545  { size_ = -1; }
547  inline void switchOn(int alignment=3)
548  { size_ = -2; alignment_=alignment;}
550  void setPersistence(int flag,int currentLength);
552  void clear();
554  void swap(CoinArrayWithLength & other);
556  void extend(int newSize);
558 
561  char * conditionalNew(long sizeWanted);
564  void conditionalDelete();
566 
571  : array_(NULL),size_(-1),offset_(0),alignment_(0)
572  { }
574  inline CoinArrayWithLength(int size)
575  : size_(-1),offset_(0),alignment_(0)
576  { array_=new char [size];}
583  CoinArrayWithLength(int size, int mode);
591  void copy(const CoinArrayWithLength & rhs, int numberBytes=-1);
593  void allocate(const CoinArrayWithLength & rhs, int numberBytes);
597  void getArray(int size);
599  void reallyFreeArray();
601  void getCapacity(int numberBytes,int numberIfNeeded=-1);
603 
604 protected:
607  char * array_;
612  int offset_;
616 };
618 
620 
621 public:
624  inline int getSize() const
626  { return size_/CoinSizeofAsInt(double); }
628  inline double * array() const
629  { return reinterpret_cast<double *> ((size_>-2) ? array_ : NULL); }
631 
634  inline void setSize(int value)
636  { size_ = value*CoinSizeofAsInt(double); }
638 
641  inline double * conditionalNew(int sizeWanted)
643  { return reinterpret_cast<double *> ( CoinArrayWithLength::conditionalNew(sizeWanted>=0 ? static_cast<long> ((sizeWanted)*CoinSizeofAsInt(double)) : -1)); }
645 
650  { array_=NULL; size_=-1;}
652  inline CoinDoubleArrayWithLength(int size)
653  { array_=new char [size*CoinSizeofAsInt(double)]; size_=-1;}
658  inline CoinDoubleArrayWithLength(int size, int mode)
659  : CoinArrayWithLength(size*CoinSizeofAsInt(double),mode) {}
662  : CoinArrayWithLength(rhs) {}
665  : CoinArrayWithLength(rhs) {}
668  { CoinArrayWithLength::operator=(rhs); return *this;}
670 };
672 
674 
675 public:
678  inline int getSize() const
682  inline CoinFactorizationDouble * array() const
683  { return reinterpret_cast<CoinFactorizationDouble *> ((size_>-2) ? array_ : NULL); }
685 
688  inline void setSize(int value)
692 
695  inline CoinFactorizationDouble * conditionalNew(int sizeWanted)
697  { return reinterpret_cast<CoinFactorizationDouble *> (CoinArrayWithLength::conditionalNew(sizeWanted>=0 ? static_cast<long> (( sizeWanted)*CoinSizeofAsInt(CoinFactorizationDouble)) : -1)); }
699 
704  { array_=NULL; size_=-1;}
707  { array_=new char [size*CoinSizeofAsInt(CoinFactorizationDouble)]; size_=-1;}
712  inline CoinFactorizationDoubleArrayWithLength(int size, int mode)
716  : CoinArrayWithLength(rhs) {}
719  : CoinArrayWithLength(rhs) {}
722  { CoinArrayWithLength::operator=(rhs); return *this;}
724 };
726 
728 
729 public:
732  inline int getSize() const
734  { return size_/CoinSizeofAsInt(long double); }
736  inline long double * array() const
737  { return reinterpret_cast<long double *> ((size_>-2) ? array_ : NULL); }
739 
742  inline void setSize(int value)
744  { size_ = value*CoinSizeofAsInt(long double); }
746 
749  inline long double * conditionalNew(int sizeWanted)
751  { return reinterpret_cast<long double *> (CoinArrayWithLength::conditionalNew(sizeWanted>=0 ? static_cast<long> (( sizeWanted)*CoinSizeofAsInt(long double)) : -1)); }
753 
758  { array_=NULL; size_=-1;}
761  { array_=new char [size*CoinSizeofAsInt(long double)]; size_=-1;}
767  : CoinArrayWithLength(size*CoinSizeofAsInt(long double),mode) {}
770  : CoinArrayWithLength(rhs) {}
773  : CoinArrayWithLength(rhs) {}
776  { CoinArrayWithLength::operator=(rhs); return *this;}
778 };
780 
782 
783 public:
786  inline int getSize() const
788  { return size_/CoinSizeofAsInt(int); }
790  inline int * array() const
791  { return reinterpret_cast<int *> ((size_>-2) ? array_ : NULL); }
793 
796  inline void setSize(int value)
798  { size_ = value*CoinSizeofAsInt(int); }
800 
803  inline int * conditionalNew(int sizeWanted)
805  { return reinterpret_cast<int *> (CoinArrayWithLength::conditionalNew(sizeWanted>=0 ? static_cast<long> (( sizeWanted)*CoinSizeofAsInt(int)) : -1)); }
807 
812  { array_=NULL; size_=-1;}
814  inline CoinIntArrayWithLength(int size)
815  { array_=new char [size*CoinSizeofAsInt(int)]; size_=-1;}
820  inline CoinIntArrayWithLength(int size, int mode)
821  : CoinArrayWithLength(size*CoinSizeofAsInt(int),mode) {}
824  : CoinArrayWithLength(rhs) {}
827  : CoinArrayWithLength(rhs) {}
830  { CoinArrayWithLength::operator=(rhs); return *this;}
832 };
834 
836 
837 public:
840  inline int getSize() const
842  { return size_/CoinSizeofAsInt(CoinBigIndex); }
844  inline CoinBigIndex * array() const
845  { return reinterpret_cast<CoinBigIndex *> ((size_>-2) ? array_ : NULL); }
847 
850  inline void setSize(int value)
852  { size_ = value*CoinSizeofAsInt(CoinBigIndex); }
854 
857  inline CoinBigIndex * conditionalNew(int sizeWanted)
859  { return reinterpret_cast<CoinBigIndex *> (CoinArrayWithLength::conditionalNew(sizeWanted>=0 ? static_cast<long> (( sizeWanted)*CoinSizeofAsInt(CoinBigIndex)) : -1)); }
861 
866  { array_=NULL; size_=-1;}
869  { array_=new char [size*CoinSizeofAsInt(CoinBigIndex)]; size_=-1;}
874  inline CoinBigIndexArrayWithLength(int size, int mode)
878  : CoinArrayWithLength(rhs) {}
881  : CoinArrayWithLength(rhs) {}
884  { CoinArrayWithLength::operator=(rhs); return *this;}
886 };
888 
890 
891 public:
894  inline int getSize() const
896  { return size_/CoinSizeofAsInt(unsigned int); }
898  inline unsigned int * array() const
899  { return reinterpret_cast<unsigned int *> ((size_>-2) ? array_ : NULL); }
901 
904  inline void setSize(int value)
906  { size_ = value*CoinSizeofAsInt(unsigned int); }
908 
911  inline unsigned int * conditionalNew(int sizeWanted)
913  { return reinterpret_cast<unsigned int *> (CoinArrayWithLength::conditionalNew(sizeWanted>=0 ? static_cast<long> (( sizeWanted)*CoinSizeofAsInt(unsigned int)) : -1)); }
915 
920  { array_=NULL; size_=-1;}
923  { array_=new char [size*CoinSizeofAsInt(unsigned int)]; size_=-1;}
928  inline CoinUnsignedIntArrayWithLength(int size, int mode)
929  : CoinArrayWithLength(size*CoinSizeofAsInt(unsigned int),mode) {}
932  : CoinArrayWithLength(rhs) {}
935  : CoinArrayWithLength(rhs) {}
938  { CoinArrayWithLength::operator=(rhs); return *this;}
940 };
942 
944 
945 public:
948  inline int getSize() const
950  { return size_/CoinSizeofAsInt(void *); }
952  inline void ** array() const
953  { return reinterpret_cast<void **> ((size_>-2) ? array_ : NULL); }
955 
958  inline void setSize(int value)
960  { size_ = value*CoinSizeofAsInt(void *); }
962 
965  inline void ** conditionalNew(int sizeWanted)
967  { return reinterpret_cast<void **> ( CoinArrayWithLength::conditionalNew(sizeWanted>=0 ? static_cast<long> ((sizeWanted)*CoinSizeofAsInt(void *)) : -1)); }
969 
974  { array_=NULL; size_=-1;}
977  { array_=new char [size*CoinSizeofAsInt(void *)]; size_=-1;}
982  inline CoinVoidStarArrayWithLength(int size, int mode)
983  : CoinArrayWithLength(size*CoinSizeofAsInt(void *),mode) {}
986  : CoinArrayWithLength(rhs) {}
989  : CoinArrayWithLength(rhs) {}
992  { CoinArrayWithLength::operator=(rhs); return *this;}
994 };
996 
998 
999 public:
1002  inline int getSize() const
1004  { return size_/lengthInBytes_; }
1006  inline void ** array() const
1007  { return reinterpret_cast<void **> ((size_>-2) ? array_ : NULL); }
1009 
1012  inline void setSize(int value)
1014  { size_ = value*lengthInBytes_; }
1016 
1019  inline char * conditionalNew(int length, int sizeWanted)
1021  { lengthInBytes_=length;return reinterpret_cast<char *> ( CoinArrayWithLength::conditionalNew(sizeWanted>=0 ? static_cast<long>
1022  ((sizeWanted)*lengthInBytes_) : -1)); }
1024 
1028  inline CoinArbitraryArrayWithLength(int length=1)
1029  { array_=NULL; size_=-1;lengthInBytes_=length;}
1031  inline CoinArbitraryArrayWithLength(int length, int size)
1032  { array_=new char [size*length]; size_=-1; lengthInBytes_=length;}
1037  inline CoinArbitraryArrayWithLength(int length, int size, int mode)
1038  : CoinArrayWithLength(size*length,mode) {lengthInBytes_=length;}
1041  : CoinArrayWithLength(rhs) {}
1044  : CoinArrayWithLength(rhs) {}
1047  { CoinArrayWithLength::operator=(rhs); return *this;}
1049 
1050 protected:
1053  int lengthInBytes_;
1056 };
1058 
1059 public:
1060 #ifndef COIN_PARTITIONS
1061 #define COIN_PARTITIONS 8
1062 #endif
1063 
1065  inline int getNumElements(int partition) const { assert (partition<COIN_PARTITIONS);
1067  return numberElementsPartition_[partition]; }
1069  inline int getNumPartitions() const
1070  { return numberPartitions_; }
1072  inline int getNumElements() const { return nElements_; }
1074  inline int startPartition(int partition) const { assert (partition<=COIN_PARTITIONS);
1075  return startPartition_[partition]; }
1077  inline const int * startPartitions() const
1078  { return startPartition_; }
1080 
1081  //-------------------------------------------------------------------
1082  // Set indices and elements
1083  //-------------------------------------------------------------------
1086  inline void setNumElementsPartition(int partition, int value) { assert (partition<COIN_PARTITIONS);
1088  if (numberPartitions_) numberElementsPartition_[partition]=value; }
1090  inline void setTempNumElementsPartition(int partition, int value) { assert (partition<COIN_PARTITIONS);
1091  numberElementsPartition_[partition]=value; }
1093  void computeNumberElements();
1095  void compact();
1098  void reserve(int n);
1100  void setPartitions(int number,const int * starts);
1102  void clearAndReset();
1104  void clearAndKeep();
1106  void clearPartition(int partition);
1107 #ifndef NDEBUG
1108  void checkClear();
1111  void checkClean();
1112 #else
1113  inline void checkClear() {};
1114  inline void checkClean() {};
1115 #endif
1116  int scan(int partition, double tolerance=0.0);
1121  void print() const;
1124 
1128  void sort();
1130 
1136  CoinPartitionedVector(int size, const int * inds, const double * elems);
1138  CoinPartitionedVector(int size, const int * inds, double element);
1141  CoinPartitionedVector(int size, const double * elements);
1143  CoinPartitionedVector(int size);
1153 protected:
1163 };
1164 #endif
CoinBigIndex * array() const
Get Array.
int getNumPartitions() const
Get number of partitions.
CoinDoubleArrayWithLength()
Default constructor - NULL.
int alignment_
Alignment wanted (power of 2)
CoinFactorizationLongDoubleArrayWithLength(const CoinFactorizationLongDoubleArrayWithLength *rhs)
Copy constructor.2.
CoinArbitraryArrayWithLength(const CoinArbitraryArrayWithLength *rhs)
Copy constructor.2.
void setPartitions(int number, const int *starts)
Setup partitions (needs end as well)
void setSize(int value)
Set the size.
CoinFactorizationDoubleArrayWithLength(int size, int mode)
Alternate Constructor - length in bytes mode - 0 size_ set to size 1 size_ set to size and zeroed...
Pointer with length in bytes.
void setVector(int numberIndices, const int *inds, const double *elems)
Set vector numberIndices, indices, and elements.
int getSize() const
Get the size.
void quickAddNonZero(int index, double element)
Insert or if exists add an element into the vector Any resulting zero elements will be made tiny...
CoinIndexedVector operator-(const CoinIndexedVector &op2)
Return the difference of two indexed vectors.
CoinIntArrayWithLength(const CoinIntArrayWithLength &rhs)
Copy constructor.
void reserve(int n)
Reserve space.
void setConstant(int size, const int *inds, double elems)
Elements set to have the same scalar value.
void getCapacity(int numberBytes, int numberIfNeeded=-1)
Get enough space (if more needed then do at least needed)
void clearAndReset()
Reset the vector (as if were just created an empty vector). Gets rid of partitions.
void operator+=(double value)
add value to every entry
int getNumElements() const
Get the size.
int * indices_
Vector indices.
CoinFactorizationLongDoubleArrayWithLength(const CoinFactorizationLongDoubleArrayWithLength &rhs)
Copy constructor.
char * conditionalNew(long sizeWanted)
Conditionally gets new array.
void copy(const CoinIndexedVector &rhs, double multiplier=1.0)
Copy the contents of one vector into another.
CoinUnsignedIntArrayWithLength(const CoinUnsignedIntArrayWithLength &rhs)
Copy constructor.
void clear()
Zero out array.
double & operator[](int i) const
Access the i&#39;th element of the full storage vector.
CoinArbitraryArrayWithLength(int length, int size)
Alternate Constructor - length in bytes - size_ -1.
typedef void(COINLINKAGE_CB *clp_callback)(Clp_Simplex *model
typedef for user call back.
void switchOff()
Set the size to -1.
int lengthInBytes_
Length in bytes.
void setElement(int index, double element)
Set an existing element in the indexed vector The first argument is the &quot;index&quot; into the elements() a...
void reallyFreeArray()
Really get rid of array with alignment.
double * conditionalNew(int sizeWanted)
Conditionally gets new array.
int offset_
Offset to get where new allocated array.
long double * array() const
Get Array.
bool packedMode() const
Gets packed mode.
CoinFactorizationDoubleArrayWithLength(int size)
Alternate Constructor - length in bytes - size_ -1.
void setSize(int value)
Set the size.
void setSize(int value)
Set the size.
int numberPartitions_
Number of partitions (0 means off)
CoinUnsignedIntArrayWithLength & operator=(const CoinUnsignedIntArrayWithLength &rhs)
Assignment operator.
CoinBigIndex * conditionalNew(int sizeWanted)
Conditionally gets new array.
void add(int index, double element)
Insert or if exists add an element into the vector Any resulting zero elements will be made tiny...
void setPersistence(int flag, int currentLength)
Does what is needed to set persistence.
CoinIndexedVector operator+(const CoinIndexedVector &op2)
Return the sum of two indexed vectors.
void checkClear()
For debug check vector is clear i.e. no elements.
CoinPartitionedVector()
Default constructor.
void print() const
Print out.
int getSize() const
Get the size.
void zero(int index)
Makes nonzero tiny.
CoinArbitraryArrayWithLength & operator=(const CoinArbitraryArrayWithLength &rhs)
Assignment operator.
~CoinPartitionedVector()
Destructor.
CoinBigIndexArrayWithLength()
Default constructor - NULL.
void setSize(int value)
Set the size.
void setCapacity()
Set the capacity to &gt;=0 if &lt;=-2.
double * denseVector() const
Get the vector as a dense vector.
bool operator!=(const CoinPackedVectorBase &rhs) const
Not equal.
CoinUnsignedIntArrayWithLength(int size, int mode)
Alternate Constructor - length in bytes mode - 0 size_ set to size 1 size_ set to size and zeroed...
void setPackedMode(bool yesNo)
Sets packed mode.
void setIndexVector(int *array)
For very temporary use when user needs to borrow an index vector.
double * elements_
Vector elements.
bool packedMode_
If true then is operating in packed mode.
void returnVector()
Return ownership of the arguments to this vector.
CoinFactorizationLongDoubleArrayWithLength()
Default constructor - NULL.
long double * conditionalNew(int sizeWanted)
Conditionally gets new array.
#define COIN_PARTITIONS
void reserve(int n)
Reserve space.
CoinBigIndexArrayWithLength(const CoinBigIndexArrayWithLength *rhs)
Copy constructor.2.
void operator*=(double value)
multiply every entry by value
void sort()
Sort the indexed storage vector (increasing indices).
const double COIN_DBL_MIN
Definition: CoinFinite.hpp:17
CoinArbitraryArrayWithLength(int length=1)
Default constructor - NULL.
int nElements_
Size of indices and packed elements vectors.
Abstract base class for various sparse vectors.
int getSize() const
Get the size.
void setNumElements(int value)
Set the size.
CoinUnsignedIntArrayWithLength(int size)
Alternate Constructor - length in bytes - size_ -1.
void swap(int i, int j)
Swap values in positions i and j of indices and elements.
CoinIntArrayWithLength(const CoinIntArrayWithLength *rhs)
Copy constructor.2.
void borrowVector(int size, int numberIndices, int *inds, double *elems)
Borrow ownership of the arguments to this vector.
int getNumElements() const
Get the size.
void print() const
Scan dense region from start to &lt; end and set up indices returns number found.
void operator-=(double value)
subtract value from every entry
int cleanAndPack(double tolerance)
Same but packs down.
CoinFactorizationDouble * array() const
Get Array.
~CoinIndexedVector()
Destructor.
#define CoinSizeofAsInt(type)
Cube Root.
double CoinFactorizationDouble
Definition: CoinTypes.hpp:57
CoinVoidStarArrayWithLength()
Default constructor - NULL.
int getSize() const
Get the size.
void setSize(int value)
Set the size.
CoinBigIndexArrayWithLength(const CoinBigIndexArrayWithLength &rhs)
Copy constructor.
CoinIntArrayWithLength(int size)
Alternate Constructor - length in bytes - size_ -1.
int getMaxIndex() const
Get value of maximum index.
void swap(CoinArrayWithLength &other)
Swaps memory between two members.
void expand()
This is mainly for testing - goes from packed to indexed.
int * conditionalNew(int sizeWanted)
Conditionally gets new array.
CoinBigIndex * version.
CoinBigIndexArrayWithLength(int size, int mode)
Alternate Constructor - length in bytes mode - 0 size_ set to size 1 size_ set to size and zeroed...
Indexed Vector.
int clean(double tolerance)
set all small values to zero and return number remaining
CoinFactorizationDoubleArrayWithLength(const CoinFactorizationDoubleArrayWithLength &rhs)
Copy constructor.
void getArray(int size)
Get array with alignment.
int scan()
Scan dense region and set up indices (returns number found)
CoinIntArrayWithLength(int size, int mode)
Alternate Constructor - length in bytes mode - 0 size_ set to size 1 size_ set to size and zeroed...
int capacity_
Amount of memory allocated for indices_, and elements_.
CoinVoidStarArrayWithLength(int size, int mode)
Alternate Constructor - length in bytes mode - 0 size_ set to size 1 size_ set to size and zeroed...
CoinFactorizationDoubleArrayWithLength(const CoinFactorizationDoubleArrayWithLength *rhs)
Copy constructor.2.
CoinArrayWithLength(int size)
Alternate Constructor - length in bytes - size_ -1.
CoinArrayWithLength & operator=(const CoinArrayWithLength &rhs)
Assignment operator.
void createOneUnpackedElement(int index, double element)
Create unpacked singleton.
void createUnpacked(int number, const int *indices, const double *elements)
Create unpacked array.
CoinDoubleArrayWithLength(const CoinDoubleArrayWithLength *rhs)
Copy constructor.2.
double * array() const
Get Array.
CoinIndexedVector operator/(const CoinIndexedVector &op2)
Return the element-wise ratio of two indexed vectors (0.0/0.0 =&gt; 0.0) (0 vanishes) ...
CoinUnsignedIntArrayWithLength(const CoinUnsignedIntArrayWithLength *rhs)
Copy constructor.2.
CoinIntArrayWithLength & operator=(const CoinIntArrayWithLength &rhs)
Assignment operator.
void empty()
Reset the vector (as if were just created an empty vector)
const int * getIndices() const
Get indices of elements.
void gutsOfSetPackedVector(int size, int numberIndices, const int *inds, const double *elems)
CoinBigIndex size_
Size of array in bytes.
void append(const CoinPackedVectorBase &caboose)
Append a CoinPackedVector to the end.
CoinVoidStarArrayWithLength(int size)
Alternate Constructor - length in bytes - size_ -1.
CoinPartitionedVector & operator=(const CoinPartitionedVector &)
Assignment operator.
void gutsOfSetConstant(int size, const int *inds, double value)
void ** array() const
Get Array.
int getSize() const
Get the size.
void setFull(int size, const double *elems)
Indices are not specified and are taken to be 0,1,...,size-1.
void sort()
Sort the indexed storage vector (increasing indices).
CoinFactorizationLongDoubleArrayWithLength(int size, int mode)
Alternate Constructor - length in bytes mode - 0 size_ set to size 1 size_ set to size and zeroed...
void ** conditionalNew(int sizeWanted)
Conditionally gets new array.
void gutsOfSetVector(int size, const int *inds, const double *elems)
Copy internal data.
int capacity() const
capacity returns the size which could be accomodated without having to reallocate storage...
CoinVoidStarArrayWithLength(const CoinVoidStarArrayWithLength *rhs)
Copy constructor.2.
CoinArrayWithLength()
Default constructor - NULL.
void checkClear()
For debug check vector is clear i.e. no elements.
void setSize(int value)
Set the size.
int offset_
Offset of array.
CoinDoubleArrayWithLength & operator=(const CoinDoubleArrayWithLength &rhs)
Assignment operator.
CoinIntArrayWithLength()
Default constructor - NULL.
void clearAndKeep()
Reset the vector (as if were just created an empty vector). Keeps partitions.
void checkClean()
For debug check vector is clean i.e. elements match indices.
int rawSize() const
Get the size.
CoinDoubleArrayWithLength(int size)
Alternate Constructor - length in bytes - size_ -1.
void CoinIndexedVectorUnitTest()
A function that tests the methods in the CoinIndexedVector class.
void conditionalDelete()
Conditionally deletes.
CoinFactorizationDoubleArrayWithLength()
Default constructor - NULL.
CoinUnsignedIntArrayWithLength()
Default constructor - NULL.
unsigned int * array() const
Get Array.
CoinVoidStarArrayWithLength & operator=(const CoinVoidStarArrayWithLength &rhs)
Assignment operator.
int isApproximatelyEqual(const CoinIndexedVector &rhs, double tolerance=1.0e-8) const
Equal with a tolerance (returns -1 or position of inequality).
void quickInsert(int index, double element)
Insert a nonzero element into the vector.
void switchOn(int alignment=3)
Set the size to -2 and alignment.
CoinFactorizationDouble * version.
int CoinBigIndex
void ** array() const
Get Array.
int numberElementsPartition_[COIN_PARTITIONS]
Size of indices in a partition.
CoinVoidStarArrayWithLength(const CoinVoidStarArrayWithLength &rhs)
Copy constructor.
void setPacked()
Mark as packed.
void compact()
Add up number of elements in partitions and pack and get rid of partitions.
CoinFactorizationLongDouble * version.
CoinFactorizationLongDoubleArrayWithLength(int size)
Alternate Constructor - length in bytes - size_ -1.
~CoinArrayWithLength()
Destructor.
int getSize() const
Get the size.
void createPacked(int number, const int *indices, const double *elements)
Create packed array.
void setNumElementsPartition(int partition, int value)
Set the size of a partition.
int * array() const
Get Array.
int startPartition_[COIN_PARTITIONS+1]
Starts.
int * getIndices()
Get element values.
char * conditionalNew(int length, int sizeWanted)
Conditionally gets new array.
CoinArbitraryArrayWithLength(const CoinArbitraryArrayWithLength &rhs)
Copy constructor.
void extend(int newSize)
Extend a persistent array keeping data (size in bytes)
CoinIndexedVector()
Default constructor.
CoinFactorizationDoubleArrayWithLength & operator=(const CoinFactorizationDoubleArrayWithLength &rhs)
Assignment operator.
void copy(const CoinArrayWithLength &rhs, int numberBytes=-1)
Assignment with length (if -1 use internal length)
int cleanAndPackSafe(double tolerance)
Same but packs down and is safe (i.e. if order is odd)
CoinArbitraryArrayWithLength(int length, int size, int mode)
Alternate Constructor - length in bytes mode - 0 size_ set to size 1 size_ set to size and zeroed...
void setTempNumElementsPartition(int partition, int value)
Set the size of a partition (just for a tiny while)
int startPartition(int partition) const
Get starts.
int capacity() const
Get the capacity (just read it)
void allocate(const CoinArrayWithLength &rhs, int numberBytes)
Assignment with length - does not copy.
int getMinIndex() const
Get value of minimum index.
CoinDoubleArrayWithLength(int size, int mode)
Alternate Constructor - length in bytes mode - 0 size_ set to size 1 size_ set to size and zeroed...
CoinBigIndexArrayWithLength & operator=(const CoinBigIndexArrayWithLength &rhs)
Assignment operator.
CoinIndexedVector operator*(const CoinIndexedVector &op2)
Return the element-wise product of two indexed vectors.
CoinIndexedVector & operator=(const CoinIndexedVector &)
Assignment operator.
void quickAdd(int index, double element)
Insert or if exists add an element into the vector Any resulting zero elements will be made tiny...
CoinFactorizationLongDoubleArrayWithLength & operator=(const CoinFactorizationLongDoubleArrayWithLength &rhs)
Assignment operator.
void clear()
Reset the vector (as if were just created an empty vector). This leaves arrays!
void setDenseVector(double *array)
For very temporary use when user needs to borrow a dense vector.
bool operator==(const CoinPackedVectorBase &rhs) const
Equal.
void computeNumberElements()
Add up number of elements in partitions.
void setCapacity(int value)
const char * array() const
Get Array.
#define COIN_INDEXED_TINY_ELEMENT
void operator/=(double value)
divide every entry by value (** 0 vanishes)
CoinDoubleArrayWithLength(const CoinDoubleArrayWithLength &rhs)
Copy constructor.
void clearPartition(int partition)
Clear a partition.
friend void CoinIndexedVectorUnitTest()
A function that tests the methods in the CoinIndexedVector class.
void checkClean()
For debug check vector is clean i.e. elements match indices.
void insert(int index, double element)
Insert an element into the vector.
unsigned int * conditionalNew(int sizeWanted)
Conditionally gets new array.
const int * startPartitions() const
Get starts.
CoinFactorizationDouble * conditionalNew(int sizeWanted)
Conditionally gets new array.
CoinBigIndexArrayWithLength(int size)
Alternate Constructor - length in bytes - size_ -1.
int getSize() const
Get the size.
void setSize(int value)
Set the size.
bool switchedOn() const
See if persistence already on.
int scanAndPack()
These are same but pack down.
void truncate(int newSize)
Throw away all entries in rows &gt;= newSize.
void setSize(int value)
Set the size.