#include <IpVector.hpp>
Public Member Functions | |
Constructor/Destructor | |
Vector (const VectorSpace *owner_space) | |
Constructor. More... | |
virtual | ~Vector () |
Destructor. More... | |
Vector * | MakeNew () const |
Create new Vector of the same type with uninitialized data. More... | |
Vector * | MakeNewCopy () const |
Create new Vector of the same type and copy the data over. More... | |
Standard BLAS-1 Operations | |
(derived classes do NOT overload these methods, instead, overload the protected versions of these methods). | |
void | Copy (const Vector &x) |
Copy the data of the vector x into this vector (DCOPY). More... | |
void | Scal (Number alpha) |
Scales the vector by scalar alpha (DSCAL) More... | |
void | Axpy (Number alpha, const Vector &x) |
Add the multiple alpha of vector x to this vector (DAXPY) More... | |
Number | Dot (const Vector &x) const |
Computes inner product of vector x with this (DDOT) More... | |
Number | Nrm2 () const |
Computes the 2-norm of this vector (DNRM2) More... | |
Number | Asum () const |
Computes the 1-norm of this vector (DASUM) More... | |
Number | Amax () const |
Computes the max-norm of this vector (based on IDAMAX) More... | |
Additional (Non-BLAS) Vector Methods | |
(derived classes do NOT overload these methods, instead, overload the protected versions of these methods). | |
void | Set (Number alpha) |
Set each element in the vector to the scalar alpha. More... | |
void | ElementWiseDivide (const Vector &x) |
Element-wise division \(y_i \gets y_i/x_i\). More... | |
void | ElementWiseMultiply (const Vector &x) |
Element-wise multiplication \(y_i \gets y_i*x_i\). More... | |
void | ElementWiseMax (const Vector &x) |
Element-wise max against entries in x. More... | |
void | ElementWiseMin (const Vector &x) |
Element-wise min against entries in x. More... | |
void | ElementWiseReciprocal () |
Reciprocates the entries in the vector. More... | |
void | ElementWiseAbs () |
Absolute values of the entries in the vector. More... | |
void | ElementWiseSqrt () |
Element-wise square root of the entries in the vector. More... | |
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) More... | |
void | AddScalar (Number scalar) |
Add scalar to every vector component. More... | |
Number | Max () const |
Returns the maximum value in the vector. More... | |
Number | Min () const |
Returns the minimum value in the vector. More... | |
Number | Sum () const |
Returns the sum of the vector entries. More... | |
Number | SumLogs () const |
Returns the sum of the logs of each vector entry. More... | |
Methods for specialized operations. | |
A prototype implementation is provided, but for efficient implementation those should be specially implemented. | |
void | AddOneVector (Number a, const Vector &v1, Number c) |
Add one vector, y = a * v1 + c * y. More... | |
void | AddTwoVectors (Number a, const Vector &v1, Number b, const Vector &v2, Number c) |
Add two vectors, y = a * v1 + b * v2 + c * y. More... | |
Number | FracToBound (const Vector &delta, Number tau) const |
Fraction to the boundary parameter. More... | |
void | AddVectorQuotient (Number a, const Vector &z, const Vector &s, Number c) |
Add the quotient of two vectors, y = a * z/s + c * y. More... | |
bool | HasValidNumbers () const |
Method for determining if all stored numbers are valid (i.e., no Inf or Nan). More... | |
Accessor methods | |
Index | Dim () const |
Dimension of the Vector. More... | |
SmartPtr< const VectorSpace > | OwnerSpace () const |
Return the owner VectorSpace. More... | |
Output methods | |
(derived classes do NOT overload these methods, instead, overload the protected versions of these methods). | |
void | Print (SmartPtr< const Journalist > jnlst, EJournalLevel level, EJournalCategory category, const std::string &name, Index indent=0, const std::string &prefix="") const |
Print the entire vector. More... | |
void | Print (const Journalist &jnlst, EJournalLevel level, EJournalCategory category, const std::string &name, Index indent=0, const std::string &prefix="") const |
![]() | |
TaggedObject () | |
Constructor. More... | |
virtual | ~TaggedObject () |
Destructor. More... | |
Tag | GetTag () const |
Users of TaggedObjects call this to update their own internal tags every time they perform the expensive operation. More... | |
bool | HasChanged (const Tag comparison_tag) const |
Users of TaggedObjects call this to check if the object HasChanged since they last updated their own internal tag. More... | |
![]() | |
ReferencedObject () | |
virtual | ~ReferencedObject () |
Index | ReferenceCount () const |
void | AddRef (const Referencer *referencer) const |
void | ReleaseRef (const Referencer *referencer) const |
![]() | |
Subject () | |
Default Constructor. More... | |
virtual | ~Subject () |
Destructor. More... | |
void | AttachObserver (Observer::NotifyType notify_type, Observer *observer) const |
Attach the specified observer (i.e., begin receiving notifications). More... | |
void | DetachObserver (Observer::NotifyType notify_type, Observer *observer) const |
Detach the specified observer (i.e., no longer receive notifications). More... | |
Protected Member Functions | |
implementation methods (derived classes MUST | |
overload these pure virtual protected methods.) | |
virtual void | CopyImpl (const Vector &x)=0 |
Copy the data of the vector x into this vector (DCOPY). More... | |
virtual void | ScalImpl (Number alpha)=0 |
Scales the vector by scalar alpha (DSCAL) More... | |
virtual void | AxpyImpl (Number alpha, const Vector &x)=0 |
Add the multiple alpha of vector x to this vector (DAXPY) More... | |
virtual Number | DotImpl (const Vector &x) const =0 |
Computes inner product of vector x with this (DDOT) More... | |
virtual Number | Nrm2Impl () const =0 |
Computes the 2-norm of this vector (DNRM2) More... | |
virtual Number | AsumImpl () const =0 |
Computes the 1-norm of this vector (DASUM) More... | |
virtual Number | AmaxImpl () const =0 |
Computes the max-norm of this vector (based on IDAMAX) More... | |
virtual void | SetImpl (Number alpha)=0 |
Set each element in the vector to the scalar alpha. More... | |
virtual void | ElementWiseDivideImpl (const Vector &x)=0 |
Element-wise division \(y_i \gets y_i/x_i\). More... | |
virtual void | ElementWiseMultiplyImpl (const Vector &x)=0 |
Element-wise multiplication \(y_i \gets y_i*x_i\). More... | |
virtual void | ElementWiseMaxImpl (const Vector &x)=0 |
Element-wise max against entries in x. More... | |
virtual void | ElementWiseMinImpl (const Vector &x)=0 |
Element-wise min against entries in x. More... | |
virtual void | ElementWiseReciprocalImpl ()=0 |
Reciprocates the elements of the vector. More... | |
virtual void | ElementWiseAbsImpl ()=0 |
Take elementwise absolute values of the elements of the vector. More... | |
virtual void | ElementWiseSqrtImpl ()=0 |
Take elementwise square-root of the elements of the vector. More... | |
virtual void | ElementWiseSgnImpl ()=0 |
Replaces entries with sgn of the entry. More... | |
virtual void | AddScalarImpl (Number scalar)=0 |
Add scalar to every component of vector. More... | |
virtual Number | MaxImpl () const =0 |
Max value in the vector. More... | |
virtual Number | MinImpl () const =0 |
Min number in the vector. More... | |
virtual Number | SumImpl () const =0 |
Sum of entries in the vector. More... | |
virtual Number | SumLogsImpl () const =0 |
Sum of logs of entries in the vector. More... | |
virtual void | AddTwoVectorsImpl (Number a, const Vector &v1, Number b, const Vector &v2, Number c) |
Add two vectors (a * v1 + b * v2). More... | |
virtual Number | FracToBoundImpl (const Vector &delta, Number tau) const |
Fraction to boundary parameter. More... | |
virtual void | AddVectorQuotientImpl (Number a, const Vector &z, const Vector &s, Number c) |
Add the quotient of two vectors. More... | |
virtual bool | HasValidNumbersImpl () const |
Method for determining if all stored numbers are valid (i.e., no Inf or Nan). More... | |
virtual void | PrintImpl (const Journalist &jnlst, EJournalLevel level, EJournalCategory category, const std::string &name, Index indent, const std::string &prefix) const =0 |
Print the entire vector. More... | |
![]() | |
void | ObjectChanged () |
Objects derived from TaggedObject MUST call this method every time their internal state changes to update the internal tag for comparison. More... | |
![]() | |
void | Notify (Observer::NotifyType notify_type) const |
Private Attributes | |
CachedResults data members | |
CachedResults< Number > | dot_cache_ |
Cache for dot products. More... | |
TaggedObject::Tag | nrm2_cache_tag_ |
Number | cached_nrm2_ |
TaggedObject::Tag | asum_cache_tag_ |
Number | cached_asum_ |
TaggedObject::Tag | amax_cache_tag_ |
Number | cached_amax_ |
TaggedObject::Tag | max_cache_tag_ |
Number | cached_max_ |
TaggedObject::Tag | min_cache_tag_ |
Number | cached_min_ |
TaggedObject::Tag | sum_cache_tag_ |
Number | cached_sum_ |
TaggedObject::Tag | sumlogs_cache_tag_ |
Number | cached_sumlogs_ |
TaggedObject::Tag | valid_cache_tag_ |
bool | cached_valid_ |
Default Compiler Generated Methods | |
(Hidden to avoid implicit creation/calling). These methods are not implemented and we do not want the compiler to implement them for us, so we declare them private and do not define them. This ensures that they will not be implicitly created/called. | |
const SmartPtr< const VectorSpace > | owner_space_ |
Vector Space. More... | |
Vector () | |
Default constructor. More... | |
Vector (const Vector &) | |
Copy constructor. More... | |
Vector & | operator= (const Vector &) |
Default Assignment Operator. More... | |
Additional Inherited Members | |
![]() | |
typedef unsigned int | Tag |
Type for the Tag values. More... | |
Vector Base Class.
This is the base class for all derived vector types. Those vectors are meant to store entities like iterates, Lagrangian multipliers, constraint values etc. The implementation of a vector type depends on the computational environment (e.g. just a double array on a shared memory machine, or distributed double arrays for a distributed memory machine.)
Deriving from Vector: This class inherits from tagged object to implement an advanced caching scheme. Because of this, the TaggedObject method ObjectChanged() must be called each time the Vector changes. If you overload the XXXX_Impl protected methods, this taken care of (along with caching if possible) for you. If you have additional methods in your derived class that change the underlying data (vector values), you MUST remember to call ObjectChanged() AFTER making the change!
Definition at line 47 of file IpVector.hpp.
|
inline |
Constructor.
It has to be given a pointer to the corresponding VectorSpace.
Definition at line 518 of file IpVector.hpp.
|
inlinevirtual |
Destructor.
Definition at line 515 of file IpVector.hpp.
|
private |
Default constructor.
|
private |
Copy constructor.
|
inline |
Create new Vector of the same type with uninitialized data.
Definition at line 536 of file IpVector.hpp.
|
inline |
Create new Vector of the same type and copy the data over.
Definition at line 541 of file IpVector.hpp.
|
inline |
Copy the data of the vector x into this vector (DCOPY).
Definition at line 549 of file IpVector.hpp.
void Ipopt::Vector::Scal | ( | Number | alpha | ) |
Scales the vector by scalar alpha (DSCAL)
Add the multiple alpha of vector x to this vector (DAXPY)
Definition at line 595 of file IpVector.hpp.
Computes inner product of vector x with this (DDOT)
Definition at line 604 of file IpVector.hpp.
|
inline |
Computes the 2-norm of this vector (DNRM2)
Definition at line 626 of file IpVector.hpp.
|
inline |
Computes the 1-norm of this vector (DASUM)
Definition at line 636 of file IpVector.hpp.
|
inline |
Computes the max-norm of this vector (based on IDAMAX)
Definition at line 646 of file IpVector.hpp.
|
inline |
Set each element in the vector to the scalar alpha.
Definition at line 682 of file IpVector.hpp.
|
inline |
Element-wise division \(y_i \gets y_i/x_i\).
Definition at line 691 of file IpVector.hpp.
|
inline |
Element-wise multiplication \(y_i \gets y_i*x_i\).
Definition at line 699 of file IpVector.hpp.
|
inline |
Element-wise max against entries in x.
Definition at line 713 of file IpVector.hpp.
|
inline |
Element-wise min against entries in x.
Definition at line 722 of file IpVector.hpp.
|
inline |
Reciprocates the entries in the vector.
Definition at line 707 of file IpVector.hpp.
|
inline |
Absolute values of the entries in the vector.
Definition at line 731 of file IpVector.hpp.
|
inline |
Element-wise square root of the entries in the vector.
Definition at line 738 of file IpVector.hpp.
|
inline |
Replaces the vector values with their sgn values ( -1 if x_i < 0, 0 if x_i == 0, and 1 if x_i > 0)
Definition at line 676 of file IpVector.hpp.
|
inline |
Add scalar to every vector component.
Definition at line 744 of file IpVector.hpp.
|
inline |
Returns the maximum value in the vector.
Definition at line 752 of file IpVector.hpp.
|
inline |
Returns the minimum value in the vector.
Definition at line 762 of file IpVector.hpp.
|
inline |
Returns the sum of the vector entries.
Definition at line 656 of file IpVector.hpp.
|
inline |
Returns the sum of the logs of each vector entry.
Definition at line 666 of file IpVector.hpp.
Add one vector, y = a * v1 + c * y.
This is automatically reduced to call AddTwoVectors.
Definition at line 772 of file IpVector.hpp.
|
inline |
Add two vectors, y = a * v1 + b * v2 + c * y.
Here, this vector is y.
Definition at line 781 of file IpVector.hpp.
Fraction to the boundary parameter.
Computes \(\alpha = \max\{\bar\alpha\in(0,1] : x + \bar\alpha \Delta \geq (1-\tau)x\}\)
Definition at line 793 of file IpVector.hpp.
|
inline |
Add the quotient of two vectors, y = a * z/s + c * y.
Definition at line 815 of file IpVector.hpp.
|
inline |
Method for determining if all stored numbers are valid (i.e., no Inf or Nan).
Definition at line 826 of file IpVector.hpp.
|
inline |
Dimension of the Vector.
Definition at line 836 of file IpVector.hpp.
|
inline |
Return the owner VectorSpace.
Definition at line 841 of file IpVector.hpp.
void Ipopt::Vector::Print | ( | SmartPtr< const Journalist > | jnlst, |
EJournalLevel | level, | ||
EJournalCategory | category, | ||
const std::string & | name, | ||
Index | indent = 0 , |
||
const std::string & | prefix = "" |
||
) | const |
Print the entire vector.
void Ipopt::Vector::Print | ( | const Journalist & | jnlst, |
EJournalLevel | level, | ||
EJournalCategory | category, | ||
const std::string & | name, | ||
Index | indent = 0 , |
||
const std::string & | prefix = "" |
||
) | const |
|
protectedpure virtual |
Copy the data of the vector x into this vector (DCOPY).
Implemented in Ipopt::DenseVector, and Ipopt::CompoundVector.
|
protectedpure virtual |
Scales the vector by scalar alpha (DSCAL)
Implemented in Ipopt::DenseVector, and Ipopt::CompoundVector.
Add the multiple alpha of vector x to this vector (DAXPY)
Implemented in Ipopt::DenseVector, and Ipopt::CompoundVector.
Computes inner product of vector x with this (DDOT)
Implemented in Ipopt::DenseVector, and Ipopt::CompoundVector.
|
protectedpure virtual |
Computes the 2-norm of this vector (DNRM2)
Implemented in Ipopt::DenseVector, and Ipopt::CompoundVector.
|
protectedpure virtual |
Computes the 1-norm of this vector (DASUM)
Implemented in Ipopt::DenseVector, and Ipopt::CompoundVector.
|
protectedpure virtual |
Computes the max-norm of this vector (based on IDAMAX)
Implemented in Ipopt::DenseVector, and Ipopt::CompoundVector.
|
protectedpure virtual |
Set each element in the vector to the scalar alpha.
Implemented in Ipopt::DenseVector, and Ipopt::CompoundVector.
|
protectedpure virtual |
Element-wise division \(y_i \gets y_i/x_i\).
Implemented in Ipopt::DenseVector, and Ipopt::CompoundVector.
|
protectedpure virtual |
Element-wise multiplication \(y_i \gets y_i*x_i\).
Implemented in Ipopt::DenseVector, and Ipopt::CompoundVector.
|
protectedpure virtual |
Element-wise max against entries in x.
Implemented in Ipopt::DenseVector, and Ipopt::CompoundVector.
|
protectedpure virtual |
Element-wise min against entries in x.
Implemented in Ipopt::DenseVector, and Ipopt::CompoundVector.
|
protectedpure virtual |
Reciprocates the elements of the vector.
Implemented in Ipopt::DenseVector, and Ipopt::CompoundVector.
|
protectedpure virtual |
Take elementwise absolute values of the elements of the vector.
Implemented in Ipopt::DenseVector, and Ipopt::CompoundVector.
|
protectedpure virtual |
Take elementwise square-root of the elements of the vector.
Implemented in Ipopt::DenseVector, and Ipopt::CompoundVector.
|
protectedpure virtual |
Replaces entries with sgn of the entry.
Implemented in Ipopt::DenseVector, and Ipopt::CompoundVector.
|
protectedpure virtual |
Add scalar to every component of vector.
Implemented in Ipopt::DenseVector, and Ipopt::CompoundVector.
|
protectedpure virtual |
Max value in the vector.
Implemented in Ipopt::DenseVector, and Ipopt::CompoundVector.
|
protectedpure virtual |
Min number in the vector.
Implemented in Ipopt::DenseVector, and Ipopt::CompoundVector.
|
protectedpure virtual |
Sum of entries in the vector.
Implemented in Ipopt::DenseVector, and Ipopt::CompoundVector.
|
protectedpure virtual |
Sum of logs of entries in the vector.
Implemented in Ipopt::DenseVector, and Ipopt::CompoundVector.
|
protectedvirtual |
Add two vectors (a * v1 + b * v2).
Result is stored in this vector.
Reimplemented in Ipopt::DenseVector, and Ipopt::CompoundVector.
|
protectedvirtual |
Fraction to boundary parameter.
Reimplemented in Ipopt::DenseVector, and Ipopt::CompoundVector.
|
protectedvirtual |
Add the quotient of two vectors.
Reimplemented in Ipopt::DenseVector, and Ipopt::CompoundVector.
|
protectedvirtual |
Method for determining if all stored numbers are valid (i.e., no Inf or Nan).
A default implementation using Asum is provided.
Reimplemented in Ipopt::CompoundVector.
|
protectedpure virtual |
Print the entire vector.
Implemented in Ipopt::DenseVector, and Ipopt::CompoundVector.
|
private |
Vector Space.
Definition at line 410 of file IpVector.hpp.
|
mutableprivate |
Cache for dot products.
Definition at line 415 of file IpVector.hpp.
|
mutableprivate |
Definition at line 417 of file IpVector.hpp.
|
mutableprivate |
Definition at line 418 of file IpVector.hpp.
|
mutableprivate |
Definition at line 420 of file IpVector.hpp.
|
mutableprivate |
Definition at line 421 of file IpVector.hpp.
|
mutableprivate |
Definition at line 423 of file IpVector.hpp.
|
mutableprivate |
Definition at line 424 of file IpVector.hpp.
|
mutableprivate |
Definition at line 426 of file IpVector.hpp.
|
mutableprivate |
Definition at line 427 of file IpVector.hpp.
|
mutableprivate |
Definition at line 429 of file IpVector.hpp.
|
mutableprivate |
Definition at line 430 of file IpVector.hpp.
|
mutableprivate |
Definition at line 432 of file IpVector.hpp.
|
mutableprivate |
Definition at line 433 of file IpVector.hpp.
|
mutableprivate |
Definition at line 435 of file IpVector.hpp.
|
mutableprivate |
Definition at line 436 of file IpVector.hpp.
|
mutableprivate |
Definition at line 438 of file IpVector.hpp.
|
mutableprivate |
Definition at line 439 of file IpVector.hpp.