6 #ifndef CoinWarmStartVector_H
7 #define CoinWarmStartVector_H
11 #pragma warning(disable : 4786)
24 template <
typename T >
163 template <
typename T >
216 const T *
const diffVals);
249 template <
typename T,
typename U >
256 inline int size0()
const {
return t_.size(); }
312 template <
typename T,
typename U >
371 template <
typename T >
380 throw CoinError(
"Old warm start not derived from CoinWarmStartVector.",
381 "generateDiff",
"CoinWarmStartVector");
388 const int oldCnt = oldVector->
size();
389 const int newCnt = newVector->
size();
391 assert(newCnt >= oldCnt);
393 unsigned int *diffNdx =
new unsigned int[newCnt];
394 T *diffVal =
new T[newCnt];
399 const T *oldVal = oldVector->
values();
400 const T *newVal = newVector->
values();
401 int numberChanged = 0;
403 for (i = 0; i < oldCnt; i++) {
404 if (oldVal[i] != newVal[i]) {
405 diffNdx[numberChanged] = i;
406 diffVal[numberChanged++] = newVal[i];
409 for (; i < newCnt; i++) {
410 diffNdx[numberChanged] = i;
411 diffVal[numberChanged++] = newVal[i];
434 template <
typename T >
442 throw CoinError(
"Diff not derived from CoinWarmStartVectorDiff.",
443 "applyDiff",
"CoinWarmStartVector");
448 const int numberChanges = diff->
sze_;
449 const unsigned int *diffNdxs = diff->
diffNdxs_;
451 T *vals = this->values_;
453 for (
int i = 0; i < numberChanges; i++) {
454 unsigned int diffNdx = diffNdxs[i];
455 T diffVal = diffVals[i];
456 vals[diffNdx] = diffVal;
464 template <
typename T >
475 diffNdxs_ =
new unsigned int[sze_];
476 memcpy(diffNdxs_, rhs.
diffNdxs_, sze_ *
sizeof(
unsigned int));
477 diffVals_ =
new T[sze_];
478 memcpy(diffVals_, rhs.
diffVals_, sze_ *
sizeof(T));
490 template <
typename T >
506 template <
typename T >
514 memcpy(
diffNdxs_, diffNdxs, sze *
sizeof(
unsigned int));
516 memcpy(
diffVals_, diffVals, sze *
sizeof(T));
Error Class thrown by an exception.
A `diff' between two CoinWarmStartVector objects.
void CoinDisjointCopyN(const T *from, const CoinBigIndex size, T *to)
This helper function copies an array to another location.
int size_
the size of the vector
virtual ~CoinWarmStartVector()
virtual CoinWarmStartDiff * clone() const
`Virtual constructor'
virtual CoinWarmStartVectorDiff & operator=(const CoinWarmStartVectorDiff< T > &rhs)
Assignment.
virtual ~CoinWarmStartVectorPair()
void assignVector(int size, T *&vec)
Assign the vector to be the warmstart information.
CoinWarmStartVector< T > t_
void clear()
Clear the data.
T * values_
the vector itself
CoinWarmStartVectorPairDiff(const CoinWarmStartVectorPairDiff< T, U > &rhs)
T * diffVals_
Array of diff values.
virtual CoinWarmStartDiff * generateDiff(const CoinWarmStart *const oldCWS) const
virtual void applyDiff(const CoinWarmStartDiff *const cwsdDiff)
void assignVector0(int size, T *&vec)
CoinWarmStartVector & operator=(const CoinWarmStartVector &rhs)
void gutsOfCopy(const CoinWarmStartVector< T > &rhs)
CoinWarmStartVector(int size, const T *vec)
virtual CoinWarmStart * clone() const
`Virtual constructor'
virtual CoinWarmStartVectorPairDiff & operator=(const CoinWarmStartVectorPairDiff< T, U > &rhs)
CoinWarmStartVectorDiff< U > udiff_
const U * values1() const
unsigned int * diffNdxs_
Array of diff indices.
virtual ~CoinWarmStartVectorPairDiff()
CoinWarmStartVector< U > u_
CoinWarmStartVectorPairDiff()
CoinWarmStartVectorPair & operator=(const CoinWarmStartVectorPair< T, U > &rhs)
CoinWarmStartVector(const CoinWarmStartVector &rhs)
CoinWarmStartVectorPair(int s0, const T *v0, int s1, const U *v1)
Copyright (C) 2000 – 2003, International Business Machines Corporation and others.
void swap(CoinWarmStartVectorDiff &rhs)
void swap(CoinWarmStartVectorPair< T, U > &rhs)
virtual CoinWarmStart * clone() const
`Virtual constructor'
void assignVector1(int size, U *&vec)
void clear()
Clear the data.
Abstract base class for warm start `diff' objects.
CoinWarmStartVectorPair(const CoinWarmStartVectorPair< T, U > &rhs)
WarmStart information that is only a vector.
CoinWarmStartVectorDiff< T > tdiff_
virtual CoinWarmStartDiff * generateDiff(const CoinWarmStart *const oldCWS) const
Generate a `diff' that can convert the warm start passed as a parameter to the warm start specified b...
virtual void applyDiff(const CoinWarmStartDiff *const cwsdDiff)
Apply diff to this warm start.
virtual ~CoinWarmStartVectorDiff()
Destructor.
int size() const
return the size of the vector
const T * values0() const
void swap(CoinWarmStartVector &rhs)
const T * values() const
return a pointer to the array of vectors
CoinWarmStartVectorPair()
void swap(CoinWarmStartVectorPairDiff< T, U > &rhs)
Abstract base class for warm start information.
int sze_
Number of entries (and allocated capacity), in units of T.
CoinWarmStartVectorDiff()
Default constructor.
virtual CoinWarmStartDiff * clone() const
`Virtual constructor'