Go to the documentation of this file.
7 #ifndef __IPVECTOR_HPP__
8 #define __IPVECTOR_HPP__
65 inline Vector* MakeNew()
const;
68 inline Vector* MakeNewCopy()
const;
98 inline Number Nrm2()
const;
101 inline Number Asum()
const;
104 inline Number Amax()
const;
119 inline void ElementWiseDivide(
124 inline void ElementWiseMultiply(
129 inline void ElementWiseMax(
134 inline void ElementWiseMin(
139 inline void ElementWiseReciprocal();
142 inline void ElementWiseAbs();
145 inline void ElementWiseSqrt();
150 inline void ElementWiseSgn();
153 inline void AddScalar(
164 inline Number Sum()
const;
167 inline Number SumLogs()
const;
180 inline void AddOneVector(
190 inline void AddTwoVectors(
202 inline Number FracToBound(
208 inline void AddVectorQuotient(
217 inline bool HasValidNumbers()
const;
222 inline Index Dim()
const;
239 const std::string& name,
241 const std::string& prefix =
""
248 const std::string& name,
250 const std::string& prefix =
""
260 virtual void CopyImpl(
265 virtual void ScalImpl(
270 virtual void AxpyImpl(
281 virtual Number Nrm2Impl()
const = 0;
284 virtual Number AsumImpl()
const = 0;
287 virtual Number AmaxImpl()
const = 0;
290 virtual void SetImpl(
295 virtual void ElementWiseDivideImpl(
300 virtual void ElementWiseMultiplyImpl(
305 virtual void ElementWiseMaxImpl(
310 virtual void ElementWiseMinImpl(
315 virtual void ElementWiseReciprocalImpl() = 0;
318 virtual void ElementWiseAbsImpl() = 0;
321 virtual void ElementWiseSqrtImpl() = 0;
324 virtual void ElementWiseSgnImpl() = 0;
327 virtual void AddScalarImpl(
332 virtual Number MaxImpl()
const = 0;
335 virtual Number MinImpl()
const = 0;
338 virtual Number SumImpl()
const = 0;
341 virtual Number SumLogsImpl()
const = 0;
347 virtual void AddTwoVectorsImpl(
356 virtual Number FracToBoundImpl(
362 virtual void AddVectorQuotientImpl(
372 virtual bool HasValidNumbersImpl()
const;
375 virtual void PrintImpl(
379 const std::string& name,
381 const std::string& prefix
478 virtual Vector* MakeNew()
const = 0;
522 owner_space_(owner_space),
530 sumlogs_cache_tag_(0),
855 #if COIN_IPOPT_VERBOSITY == 0
856 # define DBG_PRINT_VECTOR(__verbose_level, __vec_name, __vec)
858 # define DBG_PRINT_VECTOR(__verbose_level, __vec_name, __vec) \
859 if (dbg_jrnl.Verbosity() >= (__verbose_level)) { \
860 if (dbg_jrnl.Jnlst()!=NULL) { \
861 (__vec).Print(dbg_jrnl.Jnlst(), \
864 dbg_jrnl.IndentationLevel()*2, \
868 #endif //if COIN_IPOPT_VERBOSITY == 0
void ElementWiseSqrt()
Element-wise square root of the entries in the vector.
virtual Number MaxImpl() const =0
Max value in the vector.
void ElementWiseSgn()
Replaces the vector values with their sgn values ( -1 if x_i < 0, 0 if x_i == 0, and 1 if x_i > 0)
Index Max(Index a, Index b)
virtual void SetImpl(Number alpha)=0
Set each element in the vector to the scalar alpha.
virtual Number Nrm2Impl() const =0
Computes the 2-norm of this vector (DNRM2)
Vector * MakeNew() const
Create new Vector of the same type with uninitialized data.
TaggedObject::Tag nrm2_cache_tag_
Index Min(Index a, Index b)
Number Asum() const
Computes the 1-norm of this vector (DASUM)
virtual void AddTwoVectorsImpl(Number a, const Vector &v1, Number b, const Vector &v2, Number c)
Add two vectors (a * v1 + b * v2).
virtual void ElementWiseSqrtImpl()=0
Take elementwise square-root of the elements of the vector.
Number Amax() const
Computes the max-norm of this vector (based on IDAMAX)
void Axpy(Number alpha, const Vector &x)
Add the multiple alpha of vector x to this vector (DAXPY)
const SmartPtr< const VectorSpace > owner_space_
Vector Space.
virtual Number SumLogsImpl() const =0
Sum of logs of entries in the vector.
virtual Number DotImpl(const Vector &x) const =0
Computes inner product of vector x with this (DDOT)
TaggedObject::Tag asum_cache_tag_
Number Dot(const Vector &x) const
Computes inner product of vector x with this (DDOT)
This file contains a base class for all exceptions and a set of macros to help with exceptions.
virtual bool HasValidNumbersImpl() const
Method for determining if all stored numbers are valid (i.e., no Inf or Nan).
Number Sum() const
Returns the sum of the vector entries.
double Number
Type of all numbers.
void Set(Number alpha)
Set each element in the vector to the scalar alpha.
virtual Number AmaxImpl() const =0
Computes the max-norm of this vector (based on IDAMAX)
virtual Number AsumImpl() const =0
Computes the 1-norm of this vector (DASUM)
virtual void ElementWiseDivideImpl(const Vector &x)=0
Element-wise division .
void ObjectChanged()
Objects derived from TaggedObject MUST call this method every time their internal state changes to up...
EJournalLevel
Print Level Enum.
void ElementWiseMax(const Vector &x)
Element-wise max against entries in x.
SmartPtr< const VectorSpace > OwnerSpace() const
Return the owner VectorSpace.
TaggedObject::Tag min_cache_tag_
Number Max() const
Returns the maximum value in the vector.
virtual void ElementWiseMaxImpl(const Vector &x)=0
Element-wise max against entries in x.
int Index
Type of all indices of vectors, matrices etc.
virtual Number SumImpl() const =0
Sum of entries in the vector.
void Copy(const Vector &x)
Copy the data of the vector x into this vector (DCOPY).
Vector * MakeNewCopy() const
Create new Vector of the same type and copy the data over.
Template class for Smart Pointers.
Number Min() const
Returns the minimum value in the vector.
EJournalCategory
Category Selection Enum.
virtual void ElementWiseReciprocalImpl()=0
Reciprocates the elements of the vector.
bool HasValidNumbers() const
Method for determining if all stored numbers are valid (i.e., no Inf or Nan).
void AddTwoVectors(Number a, const Vector &v1, Number b, const Vector &v2, Number c)
Add two vectors, y = a * v1 + b * v2 + c * y.
virtual void AddScalarImpl(Number scalar)=0
Add scalar to every component of vector.
virtual ~Vector()
Destructor.
virtual void ElementWiseSgnImpl()=0
Replaces entries with sgn of the entry.
void ElementWiseMin(const Vector &x)
Element-wise min against entries in x.
virtual void ElementWiseMultiplyImpl(const Vector &x)=0
Element-wise multiplication .
void ElementWiseReciprocal()
Reciprocates the entries in the vector.
TaggedObject::Tag sumlogs_cache_tag_
TaggedObject::Tag amax_cache_tag_
Number SumLogs() const
Returns the sum of the logs of each vector entry.
Number Nrm2() const
Computes the 2-norm of this vector (DNRM2)
void ElementWiseMultiply(const Vector &x)
Element-wise multiplication .
virtual void CopyImpl(const Vector &x)=0
Copy the data of the vector x into this vector (DCOPY).
void AddScalar(Number scalar)
Add scalar to every vector component.
Class responsible for all message output.
Number FracToBound(const Vector &delta, Number tau) const
Fraction to the boundary parameter.
VectorSpace()
Default constructor.
virtual ~VectorSpace()
Destructor.
virtual void ElementWiseAbsImpl()=0
Take elementwise absolute values of the elements of the vector.
VectorSpace base class, corresponding to the Vector base class.
virtual void AddVectorQuotientImpl(Number a, const Vector &z, const Vector &s, Number c)
Add the quotient of two vectors.
virtual void AxpyImpl(Number alpha, const Vector &x)=0
Add the multiple alpha of vector x to this vector (DAXPY)
Tag GetTag() const
Users of TaggedObjects call this to update their own internal tags every time they perform the expens...
TaggedObject::Tag valid_cache_tag_
void ElementWiseAbs()
Absolute values of the entries in the vector.
virtual Number FracToBoundImpl(const Vector &delta, Number tau) const
Fraction to boundary parameter.
Vector()
Default constructor.
bool GetCachedResult2Dep(T &retResult, const TaggedObject *dependent1, const TaggedObject *dependent2)
Method for retrieving a cached result, proving two dependencies as a TaggedObject explicitly.
void AddVectorQuotient(Number a, const Vector &z, const Vector &s, Number c)
Add the quotient of two vectors, y = a * z/s + c * y.
const Index dim_
Dimension of the vectors in this vector space.
bool IsValid(const SmartPtr< U > &smart_ptr)
virtual Number MinImpl() const =0
Min number in the vector.
TaggedObject::Tag sum_cache_tag_
unsigned int Tag
Type for the Tag values.
void AddCachedResult2Dep(const T &result, const TaggedObject *dependent1, const TaggedObject *dependent2)
Method for adding a result to the cache, proving two dependencies as a TaggedObject explicitly.
Index Dim() const
Dimension of the Vector.
virtual void ElementWiseMinImpl(const Vector &x)=0
Element-wise min against entries in x.
DECLARE_STD_EXCEPTION(FATAL_ERROR_IN_LINEAR_SOLVER)
CachedResults< Number > dot_cache_
Cache for dot products.
Storing the reference count of all the smart pointers that currently reference it.
Index Dim() const
Accessor function for the dimension of the vectors of this type.
TaggedObject::Tag max_cache_tag_
void ElementWiseDivide(const Vector &x)
Element-wise division .
void AddOneVector(Number a, const Vector &v1, Number c)
Add one vector, y = a * v1 + c * y.