4 #ifndef CoinIndexedVector_H
5 #define CoinIndexedVector_H
9 # pragma warning(disable:4786)
21 #define COIN_INDEXED_TINY_ELEMENT 1.0e-50
22 #define COIN_INDEXED_REALLY_TINY_ELEMENT 1.0e-100
24 #define COIN_INDEXED_TINY_ELEMENT 1.0e-35
25 #define COIN_INDEXED_REALLY_TINY_ELEMENT 1.0e-39
145 #ifndef CLP_NO_VECTOR
157 void borrowVector(
int size,
int numberIndices,
int* inds,
double* elems);
168 void setVector(
int numberIndices,
const int * inds,
const double * elems);
174 void setVector(
int size,
int numberIndices,
const int * inds,
const double * elems);
177 void setConstant(
int size,
const int * inds,
double elems);
180 void setFull(
int size,
const double * elems);
188 void insert(
int index,
double element);
191 void add(
int index,
double element);
219 int clean(
double tolerance);
236 int scan(
int start,
int end);
239 int scan(
double tolerance);
243 int scan(
int start,
int end,
double tolerance);
248 int scanAndPack(
int start,
int end,
double tolerance);
251 const double * elements);
254 #ifndef CLP_NO_VECTOR
262 void swap(
int i,
int j);
283 #ifndef CLP_NO_VECTOR
400 #ifndef CLP_NO_VECTOR
413 const int * inds,
const double * elems);
415 const int * inds,
const double * elems);
417 const int * inds,
const double * elems);
420 const int * inds,
double value);
478 {
return size_!=-1; }
567 {
return reinterpret_cast<double *
> ((
size_>-2) ?
array_ : NULL); }
675 {
return reinterpret_cast<int *
> ((
size_>-2) ?
array_ : NULL); }
783 {
return reinterpret_cast<unsigned int *
> ((
size_>-2) ?
array_ : NULL); }
int getMaxIndex() const
Get value of maximum index.
int getCapacity() const
Get the capacity.
~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).
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 >=0 if <=-2.
CoinArrayWithLength & operator=(const CoinArrayWithLength &rhs)
Assignment operator.
CoinFactorizationDouble * conditionalNew(int sizeWanted)
Conditionally gets new 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.
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 operator-=(double value)
subtract value from every entry
void sortDecrElement()
Sort the indexed storage vector (increasing indices).
int capacity_
Amount of memory allocated for indices_, and elements_.
int getSize() const
Get the size.
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.
double CoinFactorizationDouble
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...
void expand()
This is mainly for testing - goes from packed to indexed.
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.
CoinFactorizationDoubleArrayWithLength(const CoinFactorizationDoubleArrayWithLength &rhs)
Copy constructor.
CoinUnsignedIntArrayWithLength(const CoinUnsignedIntArrayWithLength &rhs)
Copy constructor.
void sortIncrElement()
Sort the indexed storage vector (increasing indices).
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.
void checkClear()
For debug check vector is clear i.e. no elements.
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 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'th element of the full storage vector.
void insert(int index, double element)
Insert an element into the vector.
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.
Pointer with length in bytes.
void operator+=(double value)
add value to every entry
int getSize() const
Get the size.
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.
CoinBigIndex * array() const
Get Array.
int getSize() const
Get the size.
CoinIndexedVector operator/(const CoinIndexedVector &op2)
Return the element-wise ratio of two indexed vectors (0.0/0.0 => 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.
CoinUnsignedIntArrayWithLength()
Default constructor - NULL.
int getSize() const
Get the size.
CoinIntArrayWithLength()
Default constructor - NULL.
void gutsOfSetPackedVector(int size, int numberIndices, const int *inds, const double *elems)
Copy internal data.
friend void CoinIndexedVectorUnitTest()
A function that tests the methods in the CoinIndexedVector class.
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.
int nElements_
Size of indices and packed elements vectors.
int getSize() const
Get the size.
const char * array() const
Get Array.
bool switchedOn() const
See if persistence already on.
void setPacked()
Mark as packed.
void setSize(int value)
Set the size.
int clean(double tolerance)
set all small values to zero and return number remaining
CoinIntArrayWithLength(const CoinIntArrayWithLength *rhs)
Copy constructor.2.
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.
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.
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 "index" into the elements() a...
CoinFactorizationDoubleArrayWithLength(int size)
Alternate Constructor - length in bytes - size_ -1.
void empty()
Reset the vector (as if were just created an empty vector)
void add(int index, double element)
Insert or if exists add an element into the vector Any resulting zero elements will be made tiny...
CoinBigIndex * conditionalNew(int sizeWanted)
Conditionally gets new array.
CoinDoubleArrayWithLength(const CoinDoubleArrayWithLength &rhs)
Copy constructor.
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...
int rawSize() const
Get the size.
void allocate(const CoinArrayWithLength &rhs, int numberBytes)
Assignment with length - does not copy.
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.
CoinIntArrayWithLength(int size)
Alternate Constructor - length in bytes - size_ -1.
double * conditionalNew(int sizeWanted)
Conditionally gets new array.
CoinFactorizationDouble * version.
void gutsOfSetVector(int size, const int *inds, const double *elems)
Copy internal data.
bool packedMode_
If true then is operating in packed mode.
int size_
Size of array in bytes.
void truncate(int newSize)
Throw away all entries in rows >= newSize.
int offset_
Offset to get where new allocated array.
int getMinIndex() const
Get value of minimum index.
void setSize(int value)
Set the size.
#define COIN_INDEXED_TINY_ELEMENT
void copy(const CoinIndexedVector &rhs, double multiplier=1.0)
Copy the contents of one vector into another.
#define CoinSizeofAsInt(type)
This helper returns "sizeof" as an int.
CoinArrayWithLength(int size, int mode)
Alternate Constructor - length in bytes mode - 0 size_ set to size 1 size_ set to size and zeroed...
const int * getIndices() const
Get indices of elements.
CoinBigIndexArrayWithLength(const CoinBigIndexArrayWithLength &rhs)
Copy 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!
int * indices_
Vector indices.
int scan()
Scan dense region and set up indices (returns number found)