9 #ifndef __IPDENSEVECTOR_HPP__ 10 #define __IPDENSEVECTOR_HPP__ 20 class DenseVectorSpace;
204 const std::string& name,
206 const std::string& prefix)
const 215 const std::string& name,
217 const std::string& prefix,
325 Number* AllocateInternalStorage()
const;
329 void FreeInternalStorage(
Number* values)
const;
337 bool HasStringMetaData(
const std::string tag)
const;
341 bool HasIntegerMetaData(
const std::string tag)
const;
345 bool HasNumericMetaData(
const std::string tag)
const;
349 const std::vector<std::string>& GetStringMetaData(
const std::string& tag)
const;
353 const std::vector<Index>& GetIntegerMetaData(
const std::string& tag)
const;
357 const std::vector<Number>& GetNumericMetaData(
const std::string& tag)
const;
361 void SetStringMetaData(std::string tag, std::vector<std::string> meta_data);
365 void SetIntegerMetaData(std::string tag, std::vector<Index> meta_data);
369 void SetNumericMetaData(std::string tag, std::vector<Number> meta_data);
373 const StringMetaDataMapType& GetStringMetaData()
const;
377 const IntegerMetaDataMapType& GetIntegerMetaData()
const;
381 const NumericMetaDataMapType& GetNumericMetaData()
const;
450 StringMetaDataMapType::const_iterator iter;
451 iter = string_meta_data_.find(tag);
453 if (iter != string_meta_data_.end()) {
463 IntegerMetaDataMapType::const_iterator iter;
464 iter = integer_meta_data_.find(tag);
466 if (iter != integer_meta_data_.end()) {
476 NumericMetaDataMapType::const_iterator iter;
477 iter = numeric_meta_data_.find(tag);
479 if (iter != numeric_meta_data_.end()) {
490 StringMetaDataMapType::const_iterator iter;
491 iter = string_meta_data_.find(tag);
499 IntegerMetaDataMapType::const_iterator iter;
500 iter = integer_meta_data_.find(tag);
508 NumericMetaDataMapType::const_iterator iter;
509 iter = numeric_meta_data_.find(tag);
516 string_meta_data_[tag] = meta_data;
522 integer_meta_data_[tag] = meta_data;
528 numeric_meta_data_[tag] = meta_data;
534 return string_meta_data_;
540 return integer_meta_data_;
546 return numeric_meta_data_;
bool initialized_
Flag for Initialization.
std::map< std::string, std::vector< Number > > NumericMetaDataMapType
Number * x
Input: Starting point Output: Optimal solution.
virtual void ElementWiseAbsImpl()
take abs of the elements of the vector
virtual void ElementWiseMinImpl(const Vector &x)
Set entry to min of itself and the corresponding element in x.
const Number * ExpandedValues() const
The same as the const version of Values, but we ensure that we always return a valid array...
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 set_values_from_scalar()
Auxilliary method for setting explicitly all elements in values_ to the current scalar value...
virtual Number DotImpl(const Vector &x) const
Computes inner product of vector x with this (DDOT)
Number Scalar() const
Scalar value of all entries in a homogeneous vector.
void SetValues(const Number *x)
Set elements in the vector to the Number array x.
void AddVectorQuotientImpl(Number a, const Vector &z, const Vector &s, Number c)
Add the quotient of two vectors, y = a * z/s + c * y.
virtual void SetImpl(Number value)
Set each element in the vector to the scalar alpha.
virtual void AddScalarImpl(Number scalar)
Add scalar to every component of the vector.
DECLARE_STD_EXCEPTION(FATAL_ERROR_IN_LINEAR_SOLVER)
void SetStringMetaData(std::string tag, std::vector< std::string > meta_data)
Set meta data of type std::string by tag.
double Number
Type of all numbers.
void ObjectChanged()
Objects derived from TaggedObject MUST call this method every time their internal state changes to up...
bool HasNumericMetaData(const std::string tag) const
Check if Numeric meta exists for tag.
std::map< std::string, std::vector< Index > > IntegerMetaDataMapType
virtual void ElementWiseReciprocalImpl()
reciprocates the elements of the vector
Dense Vector Implementation.
virtual Number SumLogsImpl() const
Computes the sum of the logs of the elements of vector.
EJournalLevel
Print Level Enum.
virtual void ElementWiseSgnImpl()
Changes each entry in the vector to its sgn value.
bool homogeneous_
Flag indicating whether the vector is currently homogeneous (that is, all elements have the same valu...
This vectors space is the vector space for DenseVector.
virtual void ElementWiseDivideImpl(const Vector &x)
Element-wise division .
StringMetaDataMapType string_meta_data_
virtual void ElementWiseMultiplyImpl(const Vector &x)
Element-wise multiplication .
virtual Number Nrm2Impl() const
Computes the 2-norm of this vector (DNRM2)
void SetNumericMetaData(std::string tag, std::vector< Number > meta_data)
Set meta data of type Number by tag.
bool IsHomogeneous() const
Indicates if the vector is homogeneous (i.e., all entries have the value Scalar() ...
~DenseVectorSpace()
Destructor.
void SetIntegerMetaData(std::string tag, std::vector< Index > meta_data)
Set meta data of type Index by tag.
Template class for Smart Pointers.
Number * values_
Dense Number array of vector values.
virtual void ScalImpl(Number alpha)
Scales the vector by scalar alpha (DSCAL)
DenseVector()
Default Constructor.
VectorSpace base class, corresponding to the Vector base class.
virtual Number AmaxImpl() const
Computes the max-norm of this vector (based on IDAMAX)
NumericMetaDataMapType numeric_meta_data_
virtual Number MinImpl() const
Min value in the vector.
SmartPtr< DenseVector > MakeNewDenseVector() const
Create a new DenseVector from same VectorSpace.
void operator=(const DenseVector &)
Overloaded Equals Operator.
DenseVectorSpace(Index dim)
Constructor, requires dimension of all vector for this VectorSpace.
bool HasStringMetaData(const std::string tag) const
Check if string meta exists for tag.
void FreeInternalStorage(Number *values) const
Deallocate internal storage for the DenseVector.
virtual void ElementWiseMaxImpl(const Vector &x)
Set entry to max of itself and the corresponding element in x.
virtual void ElementWiseSqrtImpl()
take square-root of the elements of the vector
const DenseVectorSpace * owner_space_
Copy of the owner_space ptr as a DenseVectorSpace instead of a VectorSpace.
int Index
Type of all indices of vectors, matrices etc.
bool HasIntegerMetaData(const std::string tag) const
Check if Integer meta exists for tag.
virtual ~DenseVector()
Destructor.
Number * values_allocated()
Method of getting the internal values array, making sure that memory has been allocated.
Index Dim() const
Dimension of the Vector.
virtual Number MaxImpl() const
Max value in the vector.
Number * ExpandedValues()
This is the same as Values, but we add it here so that ExpandedValues can also be used for the non-co...
void CopyFromPos(Index Pos, const Vector &x)
Copy a subrange of x, starting at Pos, into the full data of this vector.
void AddTwoVectorsImpl(Number a, const Vector &v1, Number b, const Vector &v2, Number c)
Add two vectors (a * v1 + b * v2).
Class responsible for all message output.
const NumericMetaDataMapType & GetNumericMetaData() const
Get map of meta data of type Number.
virtual Vector * MakeNew() const
Instantiation of the generate MakeNew method for the VectorSpace base class.
DenseVector * MakeNewDenseVector() const
Method for creating a new vector of this specific type.
virtual void CopyImpl(const Vector &x)
Copy the data of the vector x into this vector (DCOPY).
Number * AllocateInternalStorage() const
Allocate internal storage for the DenseVector.
Number FracToBoundImpl(const Vector &delta, Number tau) const
Fraction to the boundary parameter.
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.
virtual Number SumImpl() const
Computes the sum of the lements of vector.
Number scalar_
Homogeneous value of all elements if the vector is currently homogenous.
Number * expanded_values_
Dense Number array pointer that is used for ExpandedValues.
EJournalCategory
Category Selection Enum.
IntegerMetaDataMapType integer_meta_data_
void PrintImplOffset(const Journalist &jnlst, EJournalLevel level, EJournalCategory category, const std::string &name, Index indent, const std::string &prefix, Index offset) const
std::map< std::string, std::vector< std::string > > StringMetaDataMapType
typedefs for the map variables that define meta data for the DenseVectorSpace
virtual Number AsumImpl() const
Computes the 1-norm of this vector (DASUM)
Number * Values()
Obtain pointer to the internal Number array with vector elements with the indention to change the vec...
virtual void AxpyImpl(Number alpha, const Vector &x)
Add the multiple alpha of vector x to this vector (DAXPY)
const StringMetaDataMapType & GetStringMetaData() const
Get map of meta data of type Number.
const IntegerMetaDataMapType & GetIntegerMetaData() const
Get map of meta data of type Number.