Ipopt Documentation  
 
Loading...
Searching...
No Matches
Ipopt::DenseVector Class Reference

Dense Vector Implementation. More...

#include <IpDenseVector.hpp>

+ Inheritance diagram for Ipopt::DenseVector:

Public Member Functions

Constructors / Destructors
 DenseVector (const DenseVectorSpace *owner_space)
 Default Constructor.
 
virtual ~DenseVector ()
 Destructor.
 
Additional public methods not in Vector base class.
SmartPtr< DenseVectorMakeNewDenseVector () const
 Create a new DenseVector from same VectorSpace.
 
void SetValues (const Number *x)
 Set elements in the vector to the Number array x.
 
NumberValues ()
 Obtain pointer to the internal Number array with vector elements with the intention to change the vector data.
 
const NumberValues () const
 Obtain pointer to the internal Number array with vector elements without the intention to change the vector data.
 
const NumberExpandedValues () const
 The same as the const version of Values, but we ensure that we always return a valid array, even if IsHomogeneous returns true.
 
NumberExpandedValues ()
 This is the same as Values, but we add it here so that ExpandedValues can also be used for the non-const case.
 
bool IsHomogeneous () const
 Indicates if the vector is homogeneous (i.e., all entries have the value Scalar().
 
Number Scalar () const
 Scalar value of all entries in a homogeneous vector.
 
Modifying subranges of the vector.
void CopyToPos (Index Pos, const Vector &x)
 Copy the data in x into the subrange of this vector starting at position Pos in this vector.
 
void CopyFromPos (Index Pos, const Vector &x)
 Copy a subrange of x, starting at Pos, into the full data of this vector.
 
- Public Member Functions inherited from Ipopt::Vector
VectorMakeNew () const
 Create new Vector of the same type with uninitialized data.
 
VectorMakeNewCopy () const
 Create new Vector of the same type and copy the data over.
 
bool HasValidNumbers () const
 Method for determining if all stored numbers are valid (i.e., no Inf or Nan).
 
 Vector (const VectorSpace *owner_space)
 Constructor.
 
virtual ~Vector ()
 Destructor.
 
void Copy (const Vector &x)
 Copy the data of the vector x into this vector (DCOPY).
 
void Scal (Number alpha)
 Scales the vector by scalar alpha (DSCAL)
 
void Axpy (Number alpha, const Vector &x)
 Add the multiple alpha of vector x to this vector (DAXPY)
 
Number Dot (const Vector &x) const
 Computes inner product of vector x with this (DDOT)
 
Number Nrm2 () const
 Computes the 2-norm of this vector (DNRM2)
 
Number Asum () const
 Computes the 1-norm of this vector (DASUM)
 
Number Amax () const
 Computes the max-norm of this vector (based on IDAMAX)
 
void Set (Number alpha)
 Set each element in the vector to the scalar alpha.
 
void ElementWiseDivide (const Vector &x)
 Element-wise division \(y_i \gets y_i/x_i\).
 
void ElementWiseMultiply (const Vector &x)
 Element-wise multiplication \(y_i \gets y_i*x_i\).
 
void ElementWiseSelect (const Vector &x)
 Element-wise selection \(y_i \gets sgn(y_i)x_i, if y_i != 0, else 0\).
 
void ElementWiseMax (const Vector &x)
 Element-wise max against entries in x.
 
void ElementWiseMin (const Vector &x)
 Element-wise min against entries in x.
 
void ElementWiseReciprocal ()
 Reciprocates the entries in the vector.
 
void ElementWiseAbs ()
 Absolute values of the entries in the vector.
 
void ElementWiseSqrt ()
 Element-wise square root of the entries 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)
 
void AddScalar (Number scalar)
 Add scalar to every vector component.
 
Number Max () const
 Returns the maximum value in the vector.
 
Number Min () const
 Returns the minimum value in the vector.
 
Number Sum () const
 Returns the sum of the vector entries.
 
Number SumLogs () const
 Returns the sum of the logs of each vector entry.
 
void AddOneVector (Number a, const Vector &v1, Number c)
 Add one vector, y = a * v1 + c * y.
 
void AddTwoVectors (Number a, const Vector &v1, Number b, const Vector &v2, Number c)
 Add two vectors, y = a * v1 + b * v2 + c * y.
 
Number FracToBound (const Vector &delta, Number tau) const
 Fraction to the boundary parameter.
 
void AddVectorQuotient (Number a, const Vector &z, const Vector &s, Number c)
 Add the quotient of two vectors, y = a * z/s + c * y.
 
Index Dim () const
 Dimension of the Vector.
 
SmartPtr< const VectorSpaceOwnerSpace () const
 Return the owner VectorSpace.
 
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.
 
void Print (const Journalist &jnlst, EJournalLevel level, EJournalCategory category, const std::string &name, Index indent=0, const std::string &prefix="") const
 
- Public Member Functions inherited from Ipopt::TaggedObject
 TaggedObject ()
 Constructor.
 
virtual ~TaggedObject ()
 Destructor.
 
Tag GetTag () const
 Users of TaggedObjects call this to update their own internal tags every time they perform the expensive operation.
 
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.
 
- Public Member Functions inherited from Ipopt::ReferencedObject
 ReferencedObject ()
 
virtual ~ReferencedObject ()
 
Index ReferenceCount () const
 
void AddRef (const Referencer *referencer) const
 
void ReleaseRef (const Referencer *referencer) const
 
- Public Member Functions inherited from Ipopt::Subject
 Subject ()
 Default Constructor.
 
virtual ~Subject ()
 Destructor.
 
void AttachObserver (Observer::NotifyType notify_type, Observer *observer) const
 Attach the specified observer (i.e., begin receiving notifications).
 
void DetachObserver (Observer::NotifyType notify_type, Observer *observer) const
 Detach the specified observer (i.e., no longer receive notifications).
 

Protected Member Functions

Overloaded methods from Vector base class
virtual void CopyImpl (const Vector &x)
 Copy the data of the vector x into this vector (DCOPY).
 
virtual void ScalImpl (Number alpha)
 Scales the vector by scalar alpha (DSCAL)
 
virtual void AxpyImpl (Number alpha, const Vector &x)
 Add the multiple alpha of vector x to this vector (DAXPY)
 
virtual Number DotImpl (const Vector &x) const
 Computes inner product of vector x with this (DDOT)
 
virtual Number Nrm2Impl () const
 Computes the 2-norm of this vector (DNRM2)
 
virtual Number AsumImpl () const
 Computes the 1-norm of this vector (DASUM)
 
virtual Number AmaxImpl () const
 Computes the max-norm of this vector (based on IDAMAX)
 
virtual void SetImpl (Number value)
 Set each element in the vector to the scalar alpha.
 
virtual void ElementWiseDivideImpl (const Vector &x)
 Element-wise division \(y_i \gets y_i/x_i\).
 
virtual void ElementWiseMultiplyImpl (const Vector &x)
 Element-wise multiplication \(y_i \gets y_i*x_i\).
 
virtual void ElementWiseSelectImpl (const Vector &x)
 Element-wise selection \(y_i \gets sgn(y_i)x_i, if y_i != 0, else 0\).
 
virtual void ElementWiseMaxImpl (const Vector &x)
 Element-wise max against entries in x.
 
virtual void ElementWiseMinImpl (const Vector &x)
 Element-wise min against entries in x.
 
virtual void ElementWiseReciprocalImpl ()
 Reciprocates the elements of the vector.
 
virtual void ElementWiseAbsImpl ()
 Take elementwise absolute values of the elements of the vector.
 
virtual void ElementWiseSqrtImpl ()
 Take elementwise square-root of the elements of the vector.
 
virtual void ElementWiseSgnImpl ()
 Replaces entries with sgn of the entry.
 
virtual void AddScalarImpl (Number scalar)
 Add scalar to every component of vector.
 
virtual Number MaxImpl () const
 Max value in the vector.
 
virtual Number MinImpl () const
 Min number in the vector.
 
virtual Number SumImpl () const
 Sum of entries in the vector.
 
virtual Number SumLogsImpl () const
 Sum of logs of entries in the vector.
 
Implemented specialized functions
void AddTwoVectorsImpl (Number a, const Vector &v1, Number b, const Vector &v2, Number c)
 Add two vectors (a * v1 + b * v2).
 
Number FracToBoundImpl (const Vector &delta, Number tau) const
 Fraction to the boundary parameter.
 
void AddVectorQuotientImpl (Number a, const Vector &z, const Vector &s, Number c)
 Add the quotient of two vectors, y = a * z/s + c * y.
 
Output methods
virtual void PrintImpl (const Journalist &jnlst, EJournalLevel level, EJournalCategory category, const std::string &name, Index indent, const std::string &prefix) const
 Print the entire vector.
 
void PrintImplOffset (const Journalist &jnlst, EJournalLevel level, EJournalCategory category, const std::string &name, Index indent, const std::string &prefix, Index offset) const
 
- Protected Member Functions inherited from Ipopt::Vector
virtual bool HasValidNumbersImpl () const
 Method for determining if all stored numbers are valid (i.e., no Inf or Nan).
 
- Protected Member Functions inherited from Ipopt::TaggedObject
void ObjectChanged ()
 Objects derived from TaggedObject MUST call this method every time their internal state changes to update the internal tag for comparison.
 
- Protected Member Functions inherited from Ipopt::Subject
void Notify (Observer::NotifyType notify_type) const
 

Private Member Functions

Numbervalues_allocated ()
 Get the internal values array, making sure that memory has been allocated.
 
void set_values_from_scalar ()
 Auxiliary method for setting explicitly all elements in values_ to the current scalar value.
 
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.

 DenseVector ()
 Default Constructor.
 
 DenseVector (const DenseVector &)
 Copy Constructor.
 
void operator= (const DenseVector &)
 Default Assignment Operator.
 

Private Attributes

const DenseVectorSpaceowner_space_
 Copy of the owner_space ptr as a DenseVectorSpace instead of a VectorSpace.
 
Numbervalues_
 Dense Number array of vector values.
 
Numberexpanded_values_
 Dense Number array pointer that is used for ExpandedValues.
 
bool initialized_
 Flag for Initialization.
 
bool homogeneous_
 Flag indicating whether the vector is currently homogeneous (that is, all elements have the same value).
 
Number scalar_
 Homogeneous value of all elements if the vector is currently homogeneous.
 

Friends

class ParVector
 

Additional Inherited Members

- Public Types inherited from Ipopt::TaggedObject
typedef unsigned int Tag
 Type for the Tag values.
 

Detailed Description

Dense Vector Implementation.

This is the default Vector class in Ipopt. It stores vectors in contiguous Number arrays, unless the vector has the same value in all entires. In the latter case, we call the vector "homogeneous", and we store only the values that is repeated in all elements. If you want to obtain the values of vector, use the IsHomogeneous() method to find out what status the vector is in, and then use either Values() const or Scalar() const methods to get the values. To set the values of a homogeneous method, use the Set method. To set the values of a non-homogeneous vector, use the SetValues method, or use the non-const Values method to get an array that you can overwrite. In the latter case, storage is ensured.

Definition at line 40 of file IpDenseVector.hpp.

Constructor & Destructor Documentation

◆ DenseVector() [1/3]

Ipopt::DenseVector::DenseVector ( const DenseVectorSpace owner_space)

Default Constructor.

◆ ~DenseVector()

virtual Ipopt::DenseVector::~DenseVector ( )
virtual

Destructor.

◆ DenseVector() [2/3]

Ipopt::DenseVector::DenseVector ( )
private

Default Constructor.

◆ DenseVector() [3/3]

Ipopt::DenseVector::DenseVector ( const DenseVector )
private

Copy Constructor.

Member Function Documentation

◆ MakeNewDenseVector()

SmartPtr< DenseVector > Ipopt::DenseVector::MakeNewDenseVector ( ) const
inline

Create a new DenseVector from same VectorSpace.

Definition at line 503 of file IpDenseVector.hpp.

◆ SetValues()

void Ipopt::DenseVector::SetValues ( const Number x)

Set elements in the vector to the Number array x.

◆ Values() [1/2]

Number * Ipopt::DenseVector::Values ( )
inline

Obtain pointer to the internal Number array with vector elements with the intention to change the vector data.

Attention
This does not produce a copy, and lifetime is not guaranteed!.

Definition at line 448 of file IpDenseVector.hpp.

◆ Values() [2/2]

const Number * Ipopt::DenseVector::Values ( ) const
inline

Obtain pointer to the internal Number array with vector elements without the intention to change the vector data.

Attention
This does not produce a copy, and lifetime is not guaranteed!
If this vector is currently homogeneous (i.e. IsHomogeneous returns true), then you cannot call this method. Instead, you need to use the Scalar() method.

Definition at line 468 of file IpDenseVector.hpp.

◆ ExpandedValues() [1/2]

const Number * Ipopt::DenseVector::ExpandedValues ( ) const

The same as the const version of Values, but we ensure that we always return a valid array, even if IsHomogeneous returns true.

◆ ExpandedValues() [2/2]

Number * Ipopt::DenseVector::ExpandedValues ( )
inline

This is the same as Values, but we add it here so that ExpandedValues can also be used for the non-const case.

Definition at line 95 of file IpDenseVector.hpp.

◆ IsHomogeneous()

bool Ipopt::DenseVector::IsHomogeneous ( ) const
inline

Indicates if the vector is homogeneous (i.e., all entries have the value Scalar().

Definition at line 103 of file IpDenseVector.hpp.

◆ Scalar()

Number Ipopt::DenseVector::Scalar ( ) const
inline

Scalar value of all entries in a homogeneous vector.

Definition at line 109 of file IpDenseVector.hpp.

◆ CopyToPos()

void Ipopt::DenseVector::CopyToPos ( Index  Pos,
const Vector x 
)

Copy the data in x into the subrange of this vector starting at position Pos in this vector.

Position count starts at 0.

◆ CopyFromPos()

void Ipopt::DenseVector::CopyFromPos ( Index  Pos,
const Vector x 
)

Copy a subrange of x, starting at Pos, into the full data of this vector.

Position count starts at 0.

◆ CopyImpl()

virtual void Ipopt::DenseVector::CopyImpl ( const Vector x)
protectedvirtual

Copy the data of the vector x into this vector (DCOPY).

Implements Ipopt::Vector.

◆ ScalImpl()

virtual void Ipopt::DenseVector::ScalImpl ( Number  alpha)
protectedvirtual

Scales the vector by scalar alpha (DSCAL)

Implements Ipopt::Vector.

◆ AxpyImpl()

virtual void Ipopt::DenseVector::AxpyImpl ( Number  alpha,
const Vector x 
)
protectedvirtual

Add the multiple alpha of vector x to this vector (DAXPY)

Implements Ipopt::Vector.

◆ DotImpl()

virtual Number Ipopt::DenseVector::DotImpl ( const Vector x) const
protectedvirtual

Computes inner product of vector x with this (DDOT)

Implements Ipopt::Vector.

◆ Nrm2Impl()

virtual Number Ipopt::DenseVector::Nrm2Impl ( ) const
protectedvirtual

Computes the 2-norm of this vector (DNRM2)

Implements Ipopt::Vector.

◆ AsumImpl()

virtual Number Ipopt::DenseVector::AsumImpl ( ) const
protectedvirtual

Computes the 1-norm of this vector (DASUM)

Implements Ipopt::Vector.

◆ AmaxImpl()

virtual Number Ipopt::DenseVector::AmaxImpl ( ) const
protectedvirtual

Computes the max-norm of this vector (based on IDAMAX)

Implements Ipopt::Vector.

◆ SetImpl()

virtual void Ipopt::DenseVector::SetImpl ( Number  alpha)
protectedvirtual

Set each element in the vector to the scalar alpha.

Implements Ipopt::Vector.

◆ ElementWiseDivideImpl()

virtual void Ipopt::DenseVector::ElementWiseDivideImpl ( const Vector x)
protectedvirtual

Element-wise division \(y_i \gets y_i/x_i\).

Implements Ipopt::Vector.

◆ ElementWiseMultiplyImpl()

virtual void Ipopt::DenseVector::ElementWiseMultiplyImpl ( const Vector x)
protectedvirtual

Element-wise multiplication \(y_i \gets y_i*x_i\).

Implements Ipopt::Vector.

◆ ElementWiseSelectImpl()

virtual void Ipopt::DenseVector::ElementWiseSelectImpl ( const Vector x)
protectedvirtual

Element-wise selection \(y_i \gets sgn(y_i)x_i, if y_i != 0, else 0\).

Implements Ipopt::Vector.

◆ ElementWiseMaxImpl()

virtual void Ipopt::DenseVector::ElementWiseMaxImpl ( const Vector x)
protectedvirtual

Element-wise max against entries in x.

Implements Ipopt::Vector.

◆ ElementWiseMinImpl()

virtual void Ipopt::DenseVector::ElementWiseMinImpl ( const Vector x)
protectedvirtual

Element-wise min against entries in x.

Implements Ipopt::Vector.

◆ ElementWiseReciprocalImpl()

virtual void Ipopt::DenseVector::ElementWiseReciprocalImpl ( )
protectedvirtual

Reciprocates the elements of the vector.

Implements Ipopt::Vector.

◆ ElementWiseAbsImpl()

virtual void Ipopt::DenseVector::ElementWiseAbsImpl ( )
protectedvirtual

Take elementwise absolute values of the elements of the vector.

Implements Ipopt::Vector.

◆ ElementWiseSqrtImpl()

virtual void Ipopt::DenseVector::ElementWiseSqrtImpl ( )
protectedvirtual

Take elementwise square-root of the elements of the vector.

Implements Ipopt::Vector.

◆ ElementWiseSgnImpl()

virtual void Ipopt::DenseVector::ElementWiseSgnImpl ( )
protectedvirtual

Replaces entries with sgn of the entry.

Implements Ipopt::Vector.

◆ AddScalarImpl()

virtual void Ipopt::DenseVector::AddScalarImpl ( Number  scalar)
protectedvirtual

Add scalar to every component of vector.

Implements Ipopt::Vector.

◆ MaxImpl()

virtual Number Ipopt::DenseVector::MaxImpl ( ) const
protectedvirtual

Max value in the vector.

Implements Ipopt::Vector.

◆ MinImpl()

virtual Number Ipopt::DenseVector::MinImpl ( ) const
protectedvirtual

Min number in the vector.

Implements Ipopt::Vector.

◆ SumImpl()

virtual Number Ipopt::DenseVector::SumImpl ( ) const
protectedvirtual

Sum of entries in the vector.

Implements Ipopt::Vector.

◆ SumLogsImpl()

virtual Number Ipopt::DenseVector::SumLogsImpl ( ) const
protectedvirtual

Sum of logs of entries in the vector.

Implements Ipopt::Vector.

◆ AddTwoVectorsImpl()

void Ipopt::DenseVector::AddTwoVectorsImpl ( Number  a,
const Vector v1,
Number  b,
const Vector v2,
Number  c 
)
protectedvirtual

Add two vectors (a * v1 + b * v2).

Result is stored in this vector.

Reimplemented from Ipopt::Vector.

◆ FracToBoundImpl()

Number Ipopt::DenseVector::FracToBoundImpl ( const Vector delta,
Number  tau 
) const
protectedvirtual

Fraction to the boundary parameter.

Reimplemented from Ipopt::Vector.

◆ AddVectorQuotientImpl()

void Ipopt::DenseVector::AddVectorQuotientImpl ( Number  a,
const Vector z,
const Vector s,
Number  c 
)
protectedvirtual

Add the quotient of two vectors, y = a * z/s + c * y.

Reimplemented from Ipopt::Vector.

◆ PrintImpl()

virtual void Ipopt::DenseVector::PrintImpl ( const Journalist jnlst,
EJournalLevel  level,
EJournalCategory  category,
const std::string &  name,
Index  indent,
const std::string &  prefix 
) const
inlineprotectedvirtual

Print the entire vector.

Implements Ipopt::Vector.

Definition at line 241 of file IpDenseVector.hpp.

◆ PrintImplOffset()

void Ipopt::DenseVector::PrintImplOffset ( const Journalist jnlst,
EJournalLevel  level,
EJournalCategory  category,
const std::string &  name,
Index  indent,
const std::string &  prefix,
Index  offset 
) const
protected

◆ operator=()

void Ipopt::DenseVector::operator= ( const DenseVector )
private

Default Assignment Operator.

◆ values_allocated()

Number * Ipopt::DenseVector::values_allocated ( )
inlineprivate

Get the internal values array, making sure that memory has been allocated.

Definition at line 474 of file IpDenseVector.hpp.

◆ set_values_from_scalar()

void Ipopt::DenseVector::set_values_from_scalar ( )
private

Auxiliary method for setting explicitly all elements in values_ to the current scalar value.

Friends And Related Symbol Documentation

◆ ParVector

friend class ParVector
friend

Definition at line 265 of file IpDenseVector.hpp.

Member Data Documentation

◆ owner_space_

const DenseVectorSpace* Ipopt::DenseVector::owner_space_
private

Copy of the owner_space ptr as a DenseVectorSpace instead of a VectorSpace.

Definition at line 291 of file IpDenseVector.hpp.

◆ values_

Number* Ipopt::DenseVector::values_
private

Dense Number array of vector values.

Definition at line 294 of file IpDenseVector.hpp.

◆ expanded_values_

Number* Ipopt::DenseVector::expanded_values_
mutableprivate

Dense Number array pointer that is used for ExpandedValues.

Definition at line 297 of file IpDenseVector.hpp.

◆ initialized_

bool Ipopt::DenseVector::initialized_
private

Flag for Initialization.

This flag is false, if the data has not yet been initialized.

Definition at line 306 of file IpDenseVector.hpp.

◆ homogeneous_

bool Ipopt::DenseVector::homogeneous_
private

Flag indicating whether the vector is currently homogeneous (that is, all elements have the same value).

This flag is used to determine whether the elements of the vector are stored in values_ or in scalar_.

Definition at line 314 of file IpDenseVector.hpp.

◆ scalar_

Number Ipopt::DenseVector::scalar_
private

Homogeneous value of all elements if the vector is currently homogeneous.

Definition at line 317 of file IpDenseVector.hpp.


The documentation for this class was generated from the following file: