LifeV
VectorContainer< VectorType, ContainerType > Class Template Reference

VectorContainer - LifeV vector composed by concatenating other vectors. More...

#include <VectorContainer.hpp>

+ Collaboration diagram for VectorContainer< VectorType, ContainerType >:

Private Attributes

container_Type M_container
 

Constructors & Destructor

typedef VectorType vector_Type
 
typedef std::shared_ptr< vector_TypevectorPtr_Type
 
typedef ContainerType container_Type
 
typedef container_Type::iterator iterator_Type
 
typedef container_Type::const_iterator constIterator_Type
 
 VectorContainer ()
 Constructor. More...
 
 VectorContainer (const VectorContainer &vectorContainer)
 Copy constructor. More...
 
virtual ~VectorContainer ()
 Destructor. More...
 

Operators

VectorContaineroperator= (const VectorContainer< vector_Type, container_Type > &vectorContainer)
 Operator=. More...
 
VectorContaineroperator= (const Real &scalar)
 Operator=. More...
 
VectorContaineroperator &= (const VectorContainer< vector_Type, container_Type > &vectorContainer)
 Operator&=. More...
 
Realoperator[] (const UInt &id) const
 Operator[]. More...
 
vectorPtr_Typeoperator() (const UInt &id)
 Operator() More...
 
VectorContaineroperator+= (const VectorContainer< vector_Type, container_Type > &vectorContainer)
 Operator+=. More...
 
VectorContaineroperator-= (const VectorContainer< vector_Type, container_Type > &vectorContainer)
 Operator-=. More...
 
VectorContaineroperator*= (const VectorContainer< vector_Type, container_Type > &vectorContainer)
 Operator*=. More...
 
VectorContaineroperator/= (const VectorContainer< vector_Type, container_Type > &vectorContainer)
 Operator/=. More...
 
const VectorContainer operator+ (const VectorContainer< vector_Type, container_Type > &vectorContainer) const
 Operator+. More...
 
const VectorContainer operator- (const VectorContainer< vector_Type, container_Type > &vectorContainer) const
 Operator-. More...
 
const VectorContainer operator* (const VectorContainer< vector_Type, container_Type > &vectorContainer) const
 Operator*. More...
 
const VectorContainer operator/ (const VectorContainer< vector_Type, container_Type > &vectorContainer) const
 Operator/. More...
 
VectorContaineroperator+= (const Real &scalar)
 Operator+=. More...
 
VectorContaineroperator-= (const Real &scalar)
 Operator-=. More...
 
VectorContaineroperator*= (const Real &scalar)
 Operator*=. More...
 
VectorContaineroperator/= (const Real &scalar)
 Operator/=. More...
 
const VectorContainer operator+ (const Real &scalar) const
 Operator*=. More...
 
const VectorContainer operator- (const Real &scalar) const
 Operator/=. More...
 
const VectorContainer operator* (const Real &scalar) const
 Operator*=. More...
 
const VectorContainer operator/ (const Real &scalar) const
 Operator/=. More...
 
VectorContainer operator== (const Real &scalar)
 operator== More...
 
VectorContainer operator!= (const Real &scalar)
 operator!= More...
 
VectorContainer operator< (const Real &scalar)
 operator< More...
 
VectorContainer operator> (const Real &scalar)
 operator> More...
 
VectorContainer operator<= (const Real &scalar)
 operator<= More...
 
VectorContainer operator>= (const Real &scalar)
 operator>= More...
 
VectorContainer operator && (const VectorContainer< vector_Type, container_Type > &vectorContainer)
 Logic operator&&. More...
 
VectorContainer operator|| (const VectorContainer< vector_Type, container_Type > &vectorContainer)
 Logic operator||. More...
 
VectorContainer operator! ()
 Logic operator! More...
 

Methods

Real dot (const VectorContainer< vector_Type, container_Type > &vectorContainer) const
 Dot - Scalar product. More...
 
void dot (const VectorContainer< vector_Type, container_Type > &vectorContainer, Real &scalarProduct)
 Dot - Scalar product. More...
 
void abs ()
 Abs. More...
 
void abs (VectorContainer< vector_Type, container_Type > &vectorContainer)
 
Real weightNorm2 ()
 Norm2. More...
 
VectorContainerpush_back (const VectorContainer< vector_Type, container_Type > &vectorContainer)
 push_back More...
 
VectorContainerpush_back (const vectorPtr_Type &vector_ptr)
 push_back More...
 
VectorContainerpush_front (const VectorContainer< vector_Type, container_Type > &vectorContainer)
 push_front More...
 
VectorContainerpush_front (const vectorPtr_Type &vector_ptr)
 push_front More...
 
void replace (const vectorPtr_Type &vector_ptr, const UInt &id)
 Replace. More...
 
void resize (const UInt &size)
 resize More...
 
void clear ()
 Clear. More...
 
void showMe (std::ostream &output=std::cout) const
 ShowMe. More...
 

Get Methods

UInt size () const
 Get the number of elements contained inside the VectorContainer object. More...
 
UInt vectorsNumber () const
 Get the number of vectors contained inside the VectorContainer object. More...
 

Detailed Description

template<class VectorType, class ContainerType = std::vector< std::shared_ptr< VectorType > >>
class LifeV::VectorContainer< VectorType, ContainerType >

VectorContainer - LifeV vector composed by concatenating other vectors.

Author
Cristiano Malossi

The VectorContainer class has the purpose to concatenate a certain number of different vectors providing also some general methods to perform common algebraic operations.

Type of compatible vectors
This class has been developed in order to work with:

  1. VectorEpetra
  2. boost::numeric::ublas::vector

Type of compatible containers
This class has been developed in order to work with:

  1. std::vector
  2. std::dequee
  3. std::list

NOTES

  1. The VectorContainer contains shared_ptr to vectors: if you perform an operation (such as the element by element multiplication) among two containers which hold the same vectors (or at least one), the results can be different from what expected!
  2. Up to now it has been tested only with VectorEpetra. However the design should be more or less compatible also with boost::numeric::ublas::vector.

Definition at line 84 of file VectorContainer.hpp.

Member Typedef Documentation

◆ vector_Type

typedef VectorType vector_Type

Definition at line 91 of file VectorContainer.hpp.

◆ vectorPtr_Type

typedef std::shared_ptr< vector_Type > vectorPtr_Type

Definition at line 92 of file VectorContainer.hpp.

◆ container_Type

typedef ContainerType container_Type

Definition at line 93 of file VectorContainer.hpp.

◆ iterator_Type

typedef container_Type::iterator iterator_Type

Definition at line 94 of file VectorContainer.hpp.

◆ constIterator_Type

typedef container_Type::const_iterator constIterator_Type

Definition at line 95 of file VectorContainer.hpp.

Constructor & Destructor Documentation

◆ VectorContainer() [1/2]

Constructor.

Definition at line 452 of file VectorContainer.hpp.

◆ VectorContainer() [2/2]

VectorContainer ( const VectorContainer< VectorType, ContainerType > &  vectorContainer)

Copy constructor.

Makes a copy of all the objects contained in the shared_ptr(s).

Parameters
VectorContainer- VectorContainer

Definition at line 463 of file VectorContainer.hpp.

◆ ~VectorContainer()

virtual ~VectorContainer ( )
inlinevirtual

Destructor.

Definition at line 114 of file VectorContainer.hpp.

Member Function Documentation

◆ operator=() [1/2]

VectorContainer< VectorType, ContainerType > & operator= ( const VectorContainer< vector_Type, container_Type > &  vectorContainer)

Operator=.

Make a true copy of all the objects contained in the shared_ptr(s)

Parameters
vectorContainer- VectorContainer

Definition at line 479 of file VectorContainer.hpp.

◆ operator=() [2/2]

VectorContainer< VectorType, ContainerType > & operator= ( const Real scalar)

Operator=.

Set all the components of the vector equal to a scalar quantity. Cannot be done for an empty vector!

Parameters
scalar- Scalar value

Definition at line 502 of file VectorContainer.hpp.

◆ operator &=()

VectorContainer& operator&= ( const VectorContainer< vector_Type, container_Type > &  vectorContainer)

Operator&=.

Make a copy of the shared_ptr(s), without duplicates the objects contained in them.

Parameters
vectorContainer- VectorContainer

◆ operator[]()

Real & operator[] ( const UInt id) const

Operator[].

The element access operator (by reference) has been implemented just for debugging or other special cases, because it is not efficient with this type of implementation.

Parameters
id- Element id

Definition at line 536 of file VectorContainer.hpp.

◆ operator()()

VectorContainer< VectorType, ContainerType >::vectorPtr_Type & operator() ( const UInt id)

Operator()

Vector access operator (by shared_ptr).

Parameters
id- Vector id

Definition at line 562 of file VectorContainer.hpp.

◆ operator+=() [1/2]

VectorContainer< VectorType, ContainerType > & operator+= ( const VectorContainer< vector_Type, container_Type > &  vectorContainer)

Operator+=.

Parameters
vectorContainer- VectorContainer

Definition at line 574 of file VectorContainer.hpp.

◆ operator-=() [1/2]

VectorContainer< VectorType, ContainerType > & operator-= ( const VectorContainer< vector_Type, container_Type > &  vectorContainer)

Operator-=.

Parameters
vectorContainer- VectorContainer

Definition at line 591 of file VectorContainer.hpp.

◆ operator*=() [1/2]

VectorContainer< VectorType, ContainerType > & operator*= ( const VectorContainer< vector_Type, container_Type > &  vectorContainer)

Operator*=.

Multiplication element by element of two vectors.

Parameters
vectorContainer- VectorContainer

Definition at line 608 of file VectorContainer.hpp.

◆ operator/=() [1/2]

VectorContainer< VectorType, ContainerType > & operator/= ( const VectorContainer< vector_Type, container_Type > &  vectorContainer)

Operator/=.

Division element by element of two vectors.

Parameters
vectorContainer- VectorContainer

Definition at line 625 of file VectorContainer.hpp.

◆ operator+() [1/2]

const VectorContainer< VectorType, ContainerType > operator+ ( const VectorContainer< vector_Type, container_Type > &  vectorContainer) const

Operator+.

Parameters
vectorContainer- VectorContainer

Definition at line 642 of file VectorContainer.hpp.

◆ operator-() [1/2]

const VectorContainer< VectorType, ContainerType > operator- ( const VectorContainer< vector_Type, container_Type > &  vectorContainer) const

Operator-.

Parameters
vectorContainer- VectorContainer

Definition at line 658 of file VectorContainer.hpp.

◆ operator*() [1/2]

const VectorContainer< VectorType, ContainerType > operator* ( const VectorContainer< vector_Type, container_Type > &  vectorContainer) const

Operator*.

Multiplication element by element of two vectors.

Parameters
vectorContainer- VectorContainer

Definition at line 674 of file VectorContainer.hpp.

◆ operator/() [1/2]

const VectorContainer< VectorType, ContainerType > operator/ ( const VectorContainer< vector_Type, container_Type > &  vectorContainer) const

Operator/.

Division element by element of two vectors.

Parameters
vectorContainer- VectorContainer

Definition at line 690 of file VectorContainer.hpp.

◆ operator+=() [2/2]

VectorContainer< VectorType, ContainerType > & operator+= ( const Real scalar)

Operator+=.

Multiplication of the vector by a scalar.

Parameters
scalar- Scalar value

Definition at line 706 of file VectorContainer.hpp.

◆ operator-=() [2/2]

VectorContainer< VectorType, ContainerType > & operator-= ( const Real scalar)

Operator-=.

Division of the vector by a scalar.

Parameters
scalar- Scalar value

Definition at line 723 of file VectorContainer.hpp.

◆ operator*=() [2/2]

VectorContainer< VectorType, ContainerType > & operator*= ( const Real scalar)

Operator*=.

Multiplication of the vector by a scalar.

Parameters
scalar- Scalar value

Definition at line 740 of file VectorContainer.hpp.

◆ operator/=() [2/2]

VectorContainer< VectorType, ContainerType > & operator/= ( const Real scalar)

Operator/=.

Division of the vector by a scalar.

Parameters
scalar- Scalar value

Definition at line 757 of file VectorContainer.hpp.

◆ operator+() [2/2]

const VectorContainer< VectorType, ContainerType > operator+ ( const Real scalar) const

Operator*=.

Multiplication of the vector by a scalar.

Parameters
scalar- Scalar value

Definition at line 771 of file VectorContainer.hpp.

◆ operator-() [2/2]

const VectorContainer< VectorType, ContainerType > operator- ( const Real scalar) const

Operator/=.

Division of the vector by a scalar.

Parameters
scalar- Scalar value

Definition at line 787 of file VectorContainer.hpp.

◆ operator*() [2/2]

const VectorContainer< VectorType, ContainerType > operator* ( const Real scalar) const

Operator*=.

Multiplication of the vector by a scalar.

Parameters
scalar- Scalar value

Definition at line 803 of file VectorContainer.hpp.

◆ operator/() [2/2]

const VectorContainer< VectorType, ContainerType > operator/ ( const Real scalar) const

Operator/=.

Division of the vector by a scalar.

Parameters
scalar- Scalar value

Definition at line 819 of file VectorContainer.hpp.

◆ operator==()

VectorContainer< VectorType, ContainerType > operator== ( const Real scalar)

operator==

Return a VectorContainer containing 1 where vector elements are == scalar;

Parameters
scalar- Value for the comparison.

Definition at line 851 of file VectorContainer.hpp.

◆ operator!=()

VectorContainer< VectorType, ContainerType > operator!= ( const Real scalar)

operator!=

Return a VectorContainer containing 1 where vector elements are != scalar;

Parameters
scalar- Value for the comparison.

Definition at line 872 of file VectorContainer.hpp.

◆ operator<()

VectorContainer< VectorType, ContainerType > operator< ( const Real scalar)

operator<

Return a VectorContainer containing 1 where vector elements are < scalar;

Parameters
scalar- Value for the comparison.

Definition at line 914 of file VectorContainer.hpp.

◆ operator>()

VectorContainer< VectorType, ContainerType > operator> ( const Real scalar)

operator>

Return a VectorContainer containing 1 where vector elements are > scalar;

Parameters
scalar- Value for the comparison.

Definition at line 893 of file VectorContainer.hpp.

◆ operator<=()

VectorContainer< VectorType, ContainerType > operator<= ( const Real scalar)

operator<=

Return a VectorContainer containing 1 where vector elements are <= scalar;

Parameters
scalar- Value for the comparison.

Definition at line 956 of file VectorContainer.hpp.

◆ operator>=()

VectorContainer< VectorType, ContainerType > operator>= ( const Real scalar)

operator>=

Return a VectorContainer containing 1 where vector elements are >= scalar;

Parameters
scalar- Value for the comparison.

Definition at line 935 of file VectorContainer.hpp.

◆ operator &&()

VectorContainer operator&& ( const VectorContainer< vector_Type, container_Type > &  vectorContainer)

Logic operator&&.

Return a vector containing one where both the elements are different from zero;

Parameters
vectorContainer- VectorContainer

◆ operator||()

VectorContainer< VectorType, ContainerType > operator|| ( const VectorContainer< vector_Type, container_Type > &  vectorContainer)

Logic operator||.

Return a vector containing one if one of the two elements is different from zero;

Parameters
vectorContainer- VectorContainer

Definition at line 999 of file VectorContainer.hpp.

◆ operator!()

VectorContainer< VectorType, ContainerType > operator! ( )

Logic operator!

Return a vector containing one where the elements are equal to zero;

Definition at line 1021 of file VectorContainer.hpp.

◆ dot() [1/2]

Real dot ( const VectorContainer< vector_Type, container_Type > &  vectorContainer) const

Dot - Scalar product.

Scalar product of the vectors

Parameters
vectorContainer- VectorContainer

Definition at line 1046 of file VectorContainer.hpp.

◆ dot() [2/2]

void dot ( const VectorContainer< vector_Type, container_Type > &  vectorContainer,
Real scalarProduct 
)

Dot - Scalar product.

Scalar product of the vectors

Parameters
vectorContainer- VectorContainer
scalarProduct- result

Definition at line 1065 of file VectorContainer.hpp.

◆ abs() [1/2]

void abs ( )

Abs.

Replace all the elements in the vectorContainer with their abs.

Definition at line 1080 of file VectorContainer.hpp.

◆ abs() [2/2]

void abs ( VectorContainer< vector_Type, container_Type > &  vectorContainer)

Compute the abs of the VectorContainer and return it in a new container.

Parameters
vectorContainer- The output vectorContainer containing the abs of the vector.

Definition at line 1095 of file VectorContainer.hpp.

◆ weightNorm2()

Real weightNorm2 ( )

Norm2.

Compute the weight Norm2 of the vector

Definition at line 1110 of file VectorContainer.hpp.

◆ push_back() [1/2]

VectorContainer< VectorType, ContainerType > & push_back ( const VectorContainer< vector_Type, container_Type > &  vectorContainer)

push_back

Concatenate a VectorContainer to another

Parameters
vectorContainer- VectorContainer

Definition at line 1130 of file VectorContainer.hpp.

◆ push_back() [2/2]

VectorContainer< VectorType, ContainerType > & push_back ( const vectorPtr_Type vector_ptr)

push_back

Add a vector at the end of the VectorContainer

Parameters
vector_ptr- Shared pointer to a vector

Definition at line 1147 of file VectorContainer.hpp.

◆ push_front() [1/2]

VectorContainer< VectorType, ContainerType > & push_front ( const VectorContainer< vector_Type, container_Type > &  vectorContainer)

push_front

Concatenate a VectorContainer to another inserting it at the beginning

Parameters
vectorContainer- VectorContainer

Definition at line 1161 of file VectorContainer.hpp.

◆ push_front() [2/2]

VectorContainer< VectorType, ContainerType > & push_front ( const vectorPtr_Type vector_ptr)

push_front

Add a vector at the begin of the VectorContainer

Parameters
vector_ptr- Shared pointer to a vector

Definition at line 1178 of file VectorContainer.hpp.

◆ replace()

void replace ( const vectorPtr_Type vector_ptr,
const UInt id 
)
inline

Replace.

Parameters
vector_ptr- Shared pointer to the new vector
id- id of the vector that has to be replaced

Definition at line 403 of file VectorContainer.hpp.

◆ resize()

void resize ( const UInt size)
inline

resize

Parameters
size- New size of the container

Definition at line 412 of file VectorContainer.hpp.

◆ clear()

void clear ( )
inline

Clear.

Definition at line 418 of file VectorContainer.hpp.

◆ showMe()

void showMe ( std::ostream &  output = std::cout) const

ShowMe.

Definition at line 1192 of file VectorContainer.hpp.

◆ size()

UInt size ( ) const

Get the number of elements contained inside the VectorContainer object.

Definition at line 1217 of file VectorContainer.hpp.

◆ vectorsNumber()

UInt vectorsNumber ( ) const
inline

Get the number of vectors contained inside the VectorContainer object.

Definition at line 436 of file VectorContainer.hpp.

Field Documentation

◆ M_container

container_Type M_container
private

Definition at line 445 of file VectorContainer.hpp.


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