Go to the documentation of this file.
7 #ifndef __IPDENSEVECTOR_HPP__
8 #define __IPDENSEVECTOR_HPP__
18 class DenseVectorSpace;
84 inline const Number* Values()
const;
141 virtual void CopyImpl(
240 virtual void PrintImpl(
245 const std::string& name,
247 const std::string& prefix
250 PrintImplOffset(jnlst, level, category, name, indent, prefix, 1);
258 const std::string& name,
260 const std::string& prefix,
265 friend class ParVector;
300 inline Number* values_allocated();
358 return MakeNewDenseVector();
368 inline Number* AllocateInternalStorage()
const;
371 inline void FreeInternalStorage(
381 bool HasStringMetaData(
382 const std::string& tag
387 bool HasIntegerMetaData(
388 const std::string& tag
393 bool HasNumericMetaData(
394 const std::string& tag
398 inline const std::vector<std::string>& GetStringMetaData(
399 const std::string& tag
403 inline const std::vector<Index>& GetIntegerMetaData(
404 const std::string& tag
408 inline const std::vector<Number>& GetNumericMetaData(
409 const std::string& tag
413 inline void SetStringMetaData(
414 const std::string& tag,
415 const std::vector<std::string>& meta_data
419 inline void SetIntegerMetaData(
420 const std::string& tag,
421 const std::vector<Index>& meta_data
425 inline void SetNumericMetaData(
426 const std::string& tag,
427 const std::vector<Number>& meta_data
510 const std::string& tag
513 StringMetaDataMapType::const_iterator iter;
526 const std::string& tag
529 IntegerMetaDataMapType::const_iterator iter;
542 const std::string& tag
545 NumericMetaDataMapType::const_iterator iter;
557 const std::string& tag
561 StringMetaDataMapType::const_iterator iter;
567 const std::string& tag
571 IntegerMetaDataMapType::const_iterator iter;
577 const std::string& tag
581 NumericMetaDataMapType::const_iterator iter;
587 const std::string& tag,
588 const std::vector<std::string>& meta_data
595 const std::string& tag,
596 const std::vector<Index>& meta_data
603 const std::string& tag,
604 const std::vector<Number>& meta_data
Number * values_
Dense Number array of vector values.
const NumericMetaDataMapType & GetNumericMetaData() const
Get map of meta data of type Number.
DenseVector(const DenseVector &)
Copy Constructor.
virtual ~DenseVector()
Destructor.
void CopyFromPos(Index Pos, const Vector &x)
Copy a subrange of x, starting at Pos, into the full data of this vector.
virtual Number Nrm2Impl() const
Computes the 2-norm of this vector (DNRM2)
void operator=(const DenseVector &)
Default Assignment Operator.
void set_values_from_scalar()
Auxiliary method for setting explicitly all elements in values_ to the current scalar value.
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.
virtual Number MinImpl() const
Min number in the vector.
DenseVector(const DenseVectorSpace *owner_space)
Default Constructor.
virtual Number AmaxImpl() const
Computes the max-norm of this vector (based on IDAMAX)
void AddTwoVectorsImpl(Number a, const Vector &v1, Number b, const Vector &v2, Number c)
Add two vectors (a * v1 + b * v2).
Number * Values()
Obtain pointer to the internal Number array with vector elements with the intention to change the vec...
virtual Number MaxImpl() const
Max value in the vector.
DenseVector * MakeNewDenseVector() const
Method for creating a new vector of this specific type.
This file contains a base class for all exceptions and a set of macros to help with exceptions.
std::map< std::string, std::vector< Number > > NumericMetaDataMapType
virtual Number DotImpl(const Vector &x) const
Computes inner product of vector x with this (DDOT)
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 ElementWiseSelectImpl(const Vector &x)
Element-wise selection .
virtual void ElementWiseAbsImpl()
Take elementwise absolute values of the elements of the vector.
void ObjectChanged()
Objects derived from TaggedObject MUST call this method every time their internal state changes to up...
virtual void ElementWiseMultiplyImpl(const Vector &x)
Element-wise multiplication .
EJournalLevel
Print Level Enum.
const StringMetaDataMapType & GetStringMetaData() const
Get map of meta data of type Number.
NumericMetaDataMapType numeric_meta_data_
DenseVectorSpace(Index dim)
Constructor, requires dimension of all vector for this VectorSpace.
This vectors space is the vector space for DenseVector.
virtual Number SumLogsImpl() const
Sum of logs of entries in the vector.
void FreeInternalStorage(Number *values) const
Deallocate internal storage for the DenseVector.
bool HasStringMetaData(const std::string &tag) const
Check if string meta exists for tag.
const IntegerMetaDataMapType & GetIntegerMetaData() const
Get map of meta data of type Number.
void SetValues(const Number *x)
Set elements in the vector to the Number array x.
bool IsHomogeneous() const
Indicates if the vector is homogeneous (i.e., all entries have the value Scalar().
~DenseVectorSpace()
Destructor.
Number * expanded_values_
Dense Number array pointer that is used for ExpandedValues.
std::map< std::string, std::vector< Index > > IntegerMetaDataMapType
Template class for Smart Pointers.
virtual void SetImpl(Number value)
Set each element in the vector to the scalar alpha.
EJournalCategory
Category Selection Enum.
const DenseVectorSpace * owner_space_
Copy of the owner_space ptr as a DenseVectorSpace instead of a VectorSpace.
Number scalar_
Homogeneous value of all elements if the vector is currently homogeneous.
virtual void ElementWiseMinImpl(const Vector &x)
Element-wise min against entries in x.
bool HasNumericMetaData(const std::string &tag) const
Check if Numeric meta exists for tag.
ipindex Index
Type of all indices of vectors, matrices etc.
ipnumber Number
Type of all numbers.
bool initialized_
Flag for Initialization.
virtual Number AsumImpl() const
Computes the 1-norm of this vector (DASUM)
virtual void ElementWiseMaxImpl(const Vector &x)
Element-wise max against entries in x.
void SetNumericMetaData(const std::string &tag, const std::vector< Number > &meta_data)
Set meta data of type Number by tag.
virtual void ElementWiseReciprocalImpl()
Reciprocates the elements of the vector.
Class responsible for all message output.
Number * values_allocated()
Get the internal values array, making sure that memory has been allocated.
IntegerMetaDataMapType integer_meta_data_
bool homogeneous_
Flag indicating whether the vector is currently homogeneous (that is, all elements have the same valu...
Number FracToBoundImpl(const Vector &delta, Number tau) const
Fraction to the boundary parameter.
virtual void ElementWiseSqrtImpl()
Take elementwise square-root of the elements of the vector.
VectorSpace base class, corresponding to the Vector base class.
std::map< std::string, std::vector< std::string > > StringMetaDataMapType
const Number * ExpandedValues() const
The same as the const version of Values, but we ensure that we always return a valid array,...
Number * ExpandedValues()
This is the same as Values, but we add it here so that ExpandedValues can also be used for the non-co...
Dense Vector Implementation.
void SetIntegerMetaData(const std::string &tag, const std::vector< Index > &meta_data)
Set meta data of type Index by tag.
virtual Vector * MakeNew() const
Pure virtual method for creating a new Vector of the corresponding type.
bool HasIntegerMetaData(const std::string &tag) const
Check if Integer meta exists for tag.
void SetStringMetaData(const std::string &tag, const std::vector< std::string > &meta_data)
Set meta data of type std::string by tag.
virtual void ScalImpl(Number alpha)
Scales the vector by scalar alpha (DSCAL)
virtual Number SumImpl() const
Sum of entries in the vector.
Number * AllocateInternalStorage() const
Allocate internal storage for the DenseVector.
Index Dim() const
Dimension of the Vector.
SmartPtr< DenseVector > MakeNewDenseVector() const
Create a new DenseVector from same VectorSpace.
virtual void AddScalarImpl(Number scalar)
Add scalar to every component of vector.
virtual void ElementWiseDivideImpl(const Vector &x)
Element-wise division .
virtual void AxpyImpl(Number alpha, const Vector &x)
Add the multiple alpha of vector x to this vector (DAXPY)
DECLARE_STD_EXCEPTION(FATAL_ERROR_IN_LINEAR_SOLVER)
virtual void ElementWiseSgnImpl()
Replaces entries with sgn of the entry.
Number Scalar() const
Scalar value of all entries in a homogeneous vector.
StringMetaDataMapType string_meta_data_
DenseVector()
Default Constructor.
Index Dim() const
Accessor function for the dimension of the vectors of this type.
void PrintImplOffset(const Journalist &jnlst, EJournalLevel level, EJournalCategory category, const std::string &name, Index indent, const std::string &prefix, Index offset) const