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
int getMaxIndex() const
Get value of maximum index.
int CoinBigIndex
~CoinArrayWithLength()
Destructor.
void extend(int newSize)
Extend a persistent array keeping data (size in bytes)
void setVector(int numberIndices, const int *inds, const double *elems)
Set vector numberIndices, indices, and elements.
void CoinIndexedVectorUnitTest()
A function that tests the methods in the CoinIndexedVector class.
void sortIncrIndex()
Sort the indexed storage vector (increasing indices).
CoinFactorizationLongDoubleArrayWithLength()
Default constructor - NULL.
#define COIN_PARTITIONS
CoinIndexedVector operator*(const CoinIndexedVector &op2)
Return the element-wise product of two indexed vectors.
void setSize(int value)
Set the size.
void setCapacity()
Set the capacity to &gt;=0 if &lt;=-2.
CoinArrayWithLength & operator=(const CoinArrayWithLength &rhs)
Assignment operator.
CoinFactorizationDouble * conditionalNew(int sizeWanted)
Conditionally gets new array.
void ** array() const
Get Array.
void conditionalDelete()
Conditionally deletes.
CoinUnsignedIntArrayWithLength(const CoinUnsignedIntArrayWithLength *rhs)
Copy constructor.2.
CoinFactorizationDoubleArrayWithLength()
Default constructor - NULL.
void operator/=(double value)
divide every entry by value (** 0 vanishes)
void setFull(int size, const double *elems)
Indices are not specified and are taken to be 0,1,...,size-1.
void swap(CoinArrayWithLength &other)
Swaps memory between two members.
void setSize(int value)
Set the size.
void createUnpacked(int number, const int *indices, const double *elements)
Create unpacked array.
CoinIndexedVector()
Default constructor.
void reserve(int n)
Reserve space.
CoinIntArrayWithLength & operator=(const CoinIntArrayWithLength &rhs)
Assignment operator.
void sort()
Sort the indexed storage vector (increasing indices).
void setCapacity(int value)
Reserve space.
void operator-=(double value)
subtract value from every entry
void sortDecrElement()
Sort the indexed storage vector (increasing indices).
void checkClear()
For debug check vector is clear i.e. no elements.
int numberPartitions_
Number of partitions (0 means off)
int capacity_
Amount of memory allocated for indices_, and elements_.
int getSize() const
Get the size.
CoinArbitraryArrayWithLength(const CoinArbitraryArrayWithLength &rhs)
Copy constructor.
void checkClean()
For debug check vector is clean i.e. elements match indices.
int getNumElements() const
Get the size.
CoinBigIndexArrayWithLength(int size)
Alternate Constructor - length in bytes - size_ -1.
void zero(int index)
Makes nonzero tiny.
CoinDoubleArrayWithLength(int size)
Alternate Constructor - length in bytes - size_ -1.
CoinIndexedVector & operator=(const CoinIndexedVector &)
Assignment operator.
CoinBigIndexArrayWithLength(const CoinBigIndexArrayWithLength *rhs)
Copy constructor.2.
CoinVoidStarArrayWithLength(const CoinVoidStarArrayWithLength &rhs)
Copy constructor.
CoinArbitraryArrayWithLength(const CoinArbitraryArrayWithLength *rhs)
Copy constructor.2.
int cleanAndPackSafe(double tolerance)
Same but packs down and is safe (i.e. if order is odd)
CoinFactorizationDoubleArrayWithLength & operator=(const CoinFactorizationDoubleArrayWithLength &rhs)
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...
int numberElementsPartition_[COIN_PARTITIONS]
Size of indices in a partition.
void expand()
This is mainly for testing - goes from packed to indexed.
CoinVoidStarArrayWithLength & operator=(const CoinVoidStarArrayWithLength &rhs)
Assignment operator.
void clearAndKeep()
Reset the vector (as if were just created an empty vector). Keeps partitions.
int * array() const
Get Array.
bool packedMode() const
Gets packed mode.
CoinFactorizationDoubleArrayWithLength(const CoinFactorizationDoubleArrayWithLength *rhs)
Copy constructor.2.
void setSize(int value)
Set the size.
void reserve(int n)
Reserve space.
CoinFactorizationDoubleArrayWithLength(const CoinFactorizationDoubleArrayWithLength &rhs)
Copy constructor.
int isApproximatelyEqual(const CoinIndexedVector &rhs, double tolerance=1.0e-8) const
Equal with a tolerance (returns -1 or position of inequality).
CoinUnsignedIntArrayWithLength(const CoinUnsignedIntArrayWithLength &rhs)
Copy constructor.
void sortIncrElement()
Sort the indexed storage vector (increasing indices).
CoinArbitraryArrayWithLength(int length, int size)
Alternate Constructor - length in bytes - size_ -1.
bool operator==(const CoinPackedVectorBase &rhs) const
Equal.
CoinArrayWithLength()
Default constructor - NULL.
void sortDecrIndex()
Sort the indexed storage vector (increasing indices).
double * array() const
Get Array.
CoinIndexedVector operator-(const CoinIndexedVector &op2)
Return the difference of two indexed vectors.
CoinFactorizationLongDoubleArrayWithLength(const CoinFactorizationLongDoubleArrayWithLength &rhs)
Copy constructor.
void checkClear()
For debug check vector is clear i.e. no elements.
void checkClean()
For debug check vector is clean i.e. elements match indices.
void setSize(int value)
Set the size.
void computeNumberElements()
Add up number of elements in partitions.
void switchOff()
Set the size to -1.
double * elements_
Vector elements.
void returnVector()
Return ownership of the arguments to this vector.
~CoinIndexedVector()
Destructor.
CoinIndexedVector operator+(const CoinIndexedVector &op2)
Return the sum of two indexed vectors.
CoinDoubleArrayWithLength()
Default constructor - NULL.
void getArray(int size)
Get array with alignment.
void setPackedMode(bool yesNo)
Sets packed mode.
CoinBigIndexArrayWithLength()
Default constructor - NULL.
Abstract base class for various sparse vectors.
double * denseVector() const
Get the vector as a dense vector.
double & operator[](int i) const
Access the i&#39;th element of the full storage vector.
typedef void(COINLINKAGE_CB *clp_callback)(Clp_Simplex *model
typedef for user call back.
void insert(int index, double element)
Insert an element into the vector.
int startPartition(int partition) const
Get starts.
CoinBigIndexArrayWithLength & operator=(const CoinBigIndexArrayWithLength &rhs)
Assignment operator.
CoinDoubleArrayWithLength & operator=(const CoinDoubleArrayWithLength &rhs)
Assignment operator.
void borrowVector(int size, int numberIndices, int *inds, double *elems)
Borrow ownership of the arguments to this vector.
void copy(const CoinArrayWithLength &rhs, int numberBytes=-1)
Assignment with length (if -1 use internal length)
void print() const
Print out.
void setPersistence(int flag, int currentLength)
Does what is needed to set persistence.
CoinUnsignedIntArrayWithLength & operator=(const CoinUnsignedIntArrayWithLength &rhs)
Assignment operator.
void setSize(int value)
Set the size.
double CoinFactorizationDouble
Definition: CoinTypes.hpp:57
CoinPartitionedVector & operator=(const CoinPartitionedVector &)
Assignment operator.
Pointer with length in bytes.
void operator+=(double value)
add value to every entry
const double COIN_DBL_MIN
Definition: CoinFinite.hpp:17
void operator*=(double value)
multiply every entry by value
char * conditionalNew(long sizeWanted)
Conditionally gets new array.
CoinDoubleArrayWithLength(int size, int mode)
Alternate Constructor - length in bytes mode - 0 size_ set to size 1 size_ set to size and zeroed...
CoinFactorizationDouble * array() const
Get Array.
void createOneUnpackedElement(int index, double element)
Create unpacked singleton.
CoinVoidStarArrayWithLength(const CoinVoidStarArrayWithLength *rhs)
Copy constructor.2.
CoinBigIndex * array() const
Get Array.
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...
int getSize() const
Get the size.
CoinIndexedVector operator/(const CoinIndexedVector &op2)
Return the element-wise ratio of two indexed vectors (0.0/0.0 =&gt; 0.0) (0 vanishes) ...
int * conditionalNew(int sizeWanted)
Conditionally gets new array.
unsigned int * array() const
Get Array.
int capacity() const
capacity returns the size which could be accomodated without having to reallocate storage...
void clear()
Zero out array.
~CoinPartitionedVector()
Destructor.
CoinUnsignedIntArrayWithLength()
Default constructor - NULL.
Indexed Vector.
int getSize() const
Get the size.
int getSize() const
Get the size.
CoinIntArrayWithLength()
Default constructor - NULL.
void getCapacity(int numberBytes, int numberIfNeeded=-1)
Get enough space (if more needed then do at least needed)
CoinFactorizationLongDoubleArrayWithLength(const CoinFactorizationLongDoubleArrayWithLength *rhs)
Copy constructor.2.
void gutsOfSetPackedVector(int size, int numberIndices, const int *inds, const double *elems)
Copy internal data.
void ** array() const
Get Array.
long double * conditionalNew(int sizeWanted)
Conditionally gets new array.
friend void CoinIndexedVectorUnitTest()
A function that tests the methods in the CoinIndexedVector class.
void compact()
Add up number of elements in partitions and pack and get rid of partitions.
int lengthInBytes_
Length in bytes.
void switchOn(int alignment=3)
Set the size to -2 and alignment.
int scanAndPack()
These are same but pack down.
void swap(int i, int j)
Swap values in positions i and j of indices and elements.
int * getIndices()
Get element values.
void clearAndReset()
Reset the vector (as if were just created an empty vector). Gets rid of partitions.
int nElements_
Size of indices and packed elements vectors.
int getSize() const
Get the size.
void clearPartition(int partition)
Clear a partition.
CoinVoidStarArrayWithLength()
Default constructor - NULL.
int getSize() const
Get the size.
const char * array() const
Get Array.
CoinFactorizationLongDoubleArrayWithLength(int size, int mode)
Alternate Constructor - length in bytes mode - 0 size_ set to size 1 size_ set to size and zeroed...
bool switchedOn() const
See if persistence already on.
void setPacked()
Mark as packed.
void setSize(int value)
Set the size.
void setNumElementsPartition(int partition, int value)
Set the size of a partition.
int clean(double tolerance)
set all small values to zero and return number remaining
CoinIntArrayWithLength(const CoinIntArrayWithLength *rhs)
Copy constructor.2.
void setPartitions(int number, const int *starts)
Setup partitions (needs end as well)
CoinIntArrayWithLength(const CoinIntArrayWithLength &rhs)
Copy constructor.
void gutsOfSetConstant(int size, const int *inds, double value)
Copy internal data.
void setSize(int value)
Set the size.
void createPacked(int number, const int *indices, const double *elements)
Create packed array.
void quickInsert(int index, double element)
Insert a nonzero element into the 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 append(const CoinPackedVectorBase &caboose)
Append a CoinPackedVector to the end.
int getSize() const
Get the size.
void setNumElements(int value)
Set the size.
unsigned int * conditionalNew(int sizeWanted)
Conditionally gets new array.
int getNumPartitions() const
Get number of partitions.
CoinBigIndexArrayWithLength(int size, int mode)
Alternate Constructor - length in bytes mode - 0 size_ set to size 1 size_ set to size and zeroed...
CoinArrayWithLength(int size)
Alternate Constructor - length in bytes - size_ -1.
void setIndexVector(int *array)
For very temporary use when user needs to borrow an index vector.
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...
CoinFactorizationLongDouble * version.
void print() const
Scan dense region from start to &lt; end and set up indices returns number found.
CoinFactorizationDoubleArrayWithLength(int size)
Alternate Constructor - length in bytes - size_ -1.
void empty()
Reset the vector (as if were just created an empty vector)
void reallyFreeArray()
Really get rid of array with alignment.
void add(int index, double element)
Insert or if exists add an element into the vector Any resulting zero elements will be made tiny...
CoinArbitraryArrayWithLength & operator=(const CoinArbitraryArrayWithLength &rhs)
Assignment operator.
CoinBigIndex * conditionalNew(int sizeWanted)
Conditionally gets new array.
CoinDoubleArrayWithLength(const CoinDoubleArrayWithLength &rhs)
Copy constructor.
CoinArbitraryArrayWithLength(int length=1)
Default constructor - NULL.
CoinBigIndex * version.
CoinDoubleArrayWithLength(const CoinDoubleArrayWithLength *rhs)
Copy constructor.2.
void setConstant(int size, const int *inds, double elems)
Elements set to have the same scalar value.
CoinUnsignedIntArrayWithLength(int size)
Alternate Constructor - length in bytes - size_ -1.
CoinIntArrayWithLength(int size, int mode)
Alternate Constructor - length in bytes mode - 0 size_ set to size 1 size_ set to size and zeroed...
CoinBigIndex size_
Size of array in bytes.
const int * startPartitions() const
Get starts.
void ** conditionalNew(int sizeWanted)
Conditionally gets new array.
int rawSize() const
Get the size.
void allocate(const CoinArrayWithLength &rhs, int numberBytes)
Assignment with length - does not copy.
int alignment_
Alignment wanted (power of 2)
CoinFactorizationDoubleArrayWithLength(int size, int mode)
Alternate Constructor - length in bytes mode - 0 size_ set to size 1 size_ set to size and zeroed...
void setDenseVector(double *array)
For very temporary use when user needs to borrow a dense vector.
int offset_
Offset of array.
CoinIntArrayWithLength(int size)
Alternate Constructor - length in bytes - size_ -1.
int capacity() const
Get the capacity (just read it)
double * conditionalNew(int sizeWanted)
Conditionally gets new array.
CoinFactorizationDouble * version.
void gutsOfSetVector(int size, const int *inds, const double *elems)
Copy internal data.
void setTempNumElementsPartition(int partition, int value)
Set the size of a partition (just for a tiny while)
bool packedMode_
If true then is operating in packed mode.
void sort()
Sort the indexed storage vector (increasing indices).
long double * array() const
Get Array.
void truncate(int newSize)
Throw away all entries in rows &gt;= newSize.
int offset_
Offset to get where new allocated array.
int getMinIndex() const
Get value of minimum index.
CoinFactorizationLongDoubleArrayWithLength & operator=(const CoinFactorizationLongDoubleArrayWithLength &rhs)
Assignment operator.
CoinVoidStarArrayWithLength(int size, int mode)
Alternate Constructor - length in bytes mode - 0 size_ set to size 1 size_ set to size and zeroed...
void setSize(int value)
Set the size.
#define COIN_INDEXED_TINY_ELEMENT
void quickAddNonZero(int index, double element)
Insert or if exists add an element into the vector Any resulting zero elements will be made tiny...
void copy(const CoinIndexedVector &rhs, double multiplier=1.0)
Copy the contents of one vector into another.
void sortPacked()
Sort the indexed storage vector (increasing indices).
int startPartition_[COIN_PARTITIONS+1]
Starts.
#define CoinSizeofAsInt(type)
Cube Root.
const int * getIndices() const
Get indices of elements.
int getNumElements() const
Get the size.
CoinVoidStarArrayWithLength(int size)
Alternate Constructor - length in bytes - size_ -1.
char * conditionalNew(int length, int sizeWanted)
Conditionally gets new array.
CoinBigIndexArrayWithLength(const CoinBigIndexArrayWithLength &rhs)
Copy constructor.
CoinPartitionedVector()
Default constructor.
int cleanAndPack(double tolerance)
Same but packs down.
void clear()
Reset the vector (as if were just created an empty vector). This leaves arrays!
CoinFactorizationLongDoubleArrayWithLength(int size)
Alternate Constructor - length in bytes - size_ -1.
int * indices_
Vector indices.
int scan()
Scan dense region and set up indices (returns number found)