Medusa  1.1
Coordinate Free Mehless Method implementation
mm::VectorField< Scalar, dimension > Class Template Reference

#include <VectorField_fwd.hpp>

Detailed Description

template<typename Scalar, int dimension>
class mm::VectorField< Scalar, dimension >

Represents a discretization of a vector field, a finite collection of vectors.

The vector field is stored in a ColMajor fashion. This type is fully compatible with Eigen types and can use the same API. It also supports iteration over columns.

Template Parameters
Scalar
dimensionDimensionality of the vector field.

Usage example:

int n = 7;
int s = v.size(); // returns the number of elements
assert(s == v.dim*n);
assert(n == v.rows());
v = 0.0; // set to constant value
v = Vec2d(3.8, 5.6); // set to constant vector
v(4, 0) = -1.2; // set one coefficient
v[3][1] = 4.5; // set one coefficient, alternative syntax
v[4] = Vec2d(3.4, 5.2); // set one vector
v[{1, 3, 4}] = Vec2d(-4.5, 2.5); // set a subfield to a constant vector
v[{0, 6, 2}] = 0.0; // set a subfield to a constant scalar
auto c = v.c(0); // get all first components
// you can do any matrix operators with the vector field:
v *= -2.4;
v += v;
std::cout << v << std::endl;
// convert to and from linear representation
Eigen::VectorXd x = v.asLinear();
Warning
The .size() method inherited from Eigen returns the number of all elements, e. g. number of vectors multiplied by the dimension. Use .rows() method to get only the number of vectors in the vector field.

Definition at line 38 of file VectorField_fwd.hpp.

+ Inheritance diagram for mm::VectorField< Scalar, dimension >:
+ Collaboration diagram for mm::VectorField< Scalar, dimension >:

Public Member Functions

 VectorField (void)
 Construct a vector field of size 0. More...
 
 VectorField (const VectorField &)=default
 Default copy constructor. More...
 
VectorFieldoperator= (const VectorField &)=default
 Default copy assignment. More...
 
 VectorField (VectorField &&) noexcept=default
 Default move constructor. More...
 
VectorFieldoperator= (VectorField &&) noexcept=default
 Default move assignment. More...
 
template<typename OtherDerived >
 VectorField (const Eigen::MatrixBase< OtherDerived > &other)
 Allows construction of VectorField from Eigen expressions. More...
 
template<typename OtherDerived >
VectorFieldoperator= (const Eigen::MatrixBase< OtherDerived > &other)
 Assignments of Eigen expressions to VectorField. More...
 
template<typename SizeType >
 VectorField (SizeType N)
 Construct a vector field on N points. More...
 
VectorFieldoperator= (const Vec< Scalar, dimension > &v)
 Assigns vector field to be a constant vector v. More...
 
Eigen::Transpose< typename Base::RowXpr > operator[] (typename Eigen::Index i)
 Return a single row as a vector, non-const version. More...
 
SINL Eigen::Transpose< typename Base::ConstRowXpr > operator[] (typename Eigen::Index i) const
 Return a single row as a vector, const version. More...
 
SINL Eigen::Transpose< typename Base::RowXpr > operator() (typename Eigen::Index i)
 Return a single row as a vector, non-const version. More...
 
SINL Eigen::Transpose< typename Base::ConstRowXpr > operator() (typename Eigen::Index i) const
 Return a single row as a vector, const version. More...
 
SINL Base::ColXpr c (typename Eigen::Index i)
 Return the i-th component of this vector field. More...
 
SINL Base::ConstColXpr c (typename Eigen::Index i) const
 Const version of VectorField::c(). More...
 
Eigen::IndexedView< Base, indexes_t, Eigen::internal::AllRange< dimension > > SINL operator() (const indexes_t &rowIndices)
 Return an indexed view to a subset of vectors. More...
 
SINL VectorFieldView operator[] (const indexes_t &indexes)
 Returns an indexed view to a subset of vectors, that can be assigned. More...
 
Scalar * begin ()
 Pointer to the first coefficient. More...
 
const Scalar * begin () const
 Pointer to the first coefficient. More...
 
Scalar * end ()
 Pointer to the last coefficient. More...
 
const Scalar * end () const
 Const pointer to the last coefficient. More...
 
const Scalar * cbegin () const
 Const version of begin. More...
 
const Scalar * cend () const
 Const version of end. More...
 

Static Public Member Functions

template<typename OtherDerived >
static VectorField fromLinear (const Eigen::PlainObjectBase< OtherDerived > &other)
 Construct VectorField from its linear representation, obtained from asLinear(). More...
 

Public Types

typedef Scalar scalar_t
 Scalar data type. More...
 
typedef Eigen::Matrix< Scalar, Eigen::Dynamic, dimension > Base
 Base class. More...
 

Classes

class  VectorFieldView
 Represents a non contiguous view to a vector field. More...
 

Constructor & Destructor Documentation

◆ VectorField() [1/5]

template<typename Scalar , int dimension>
mm::VectorField< Scalar, dimension >::VectorField ( void  )
inline

Construct a vector field of size 0.

Definition at line 45 of file VectorField_fwd.hpp.

◆ VectorField() [2/5]

template<typename Scalar , int dimension>
mm::VectorField< Scalar, dimension >::VectorField ( const VectorField< Scalar, dimension > &  )
default

Default copy constructor.

◆ VectorField() [3/5]

template<typename Scalar , int dimension>
mm::VectorField< Scalar, dimension >::VectorField ( VectorField< Scalar, dimension > &&  )
defaultnoexcept

Default move constructor.

◆ VectorField() [4/5]

template<typename Scalar , int dimension>
template<typename OtherDerived >
mm::VectorField< Scalar, dimension >::VectorField ( const Eigen::MatrixBase< OtherDerived > &  other)

Allows construction of VectorField from Eigen expressions.

Definition at line 15 of file VectorField.hpp.

◆ VectorField() [5/5]

template<typename Scalar , int dimension>
template<typename SizeType >
mm::VectorField< Scalar, dimension >::VectorField ( SizeType  N)
inlineexplicit

Construct a vector field on N points.

Allocates the appropriate space, the values are initialized as specified by Eigen's default initialization.

Definition at line 68 of file VectorField_fwd.hpp.

Member Function Documentation

◆ begin() [1/2]

template<typename Scalar , int dimension>
Scalar* mm::VectorField< Scalar, dimension >::begin ( )
inline

Pointer to the first coefficient.

Definition at line 132 of file VectorField_fwd.hpp.

◆ begin() [2/2]

template<typename Scalar , int dimension>
const Scalar* mm::VectorField< Scalar, dimension >::begin ( ) const
inline

Pointer to the first coefficient.

Definition at line 134 of file VectorField_fwd.hpp.

◆ c() [1/2]

template<typename Scalar , int dimension>
SINL Base::ColXpr mm::VectorField< Scalar, dimension >::c ( typename Eigen::Index  i)
inline

Return the i-th component of this vector field.

The result of this function can be treated as a scalar field.

Definition at line 116 of file VectorField_fwd.hpp.

◆ c() [2/2]

template<typename Scalar , int dimension>
SINL Base::ConstColXpr mm::VectorField< Scalar, dimension >::c ( typename Eigen::Index  i) const
inline

Const version of VectorField::c().

See also
c

Definition at line 118 of file VectorField_fwd.hpp.

◆ cbegin()

template<typename Scalar , int dimension>
const Scalar* mm::VectorField< Scalar, dimension >::cbegin ( ) const
inline

Const version of begin.

Definition at line 142 of file VectorField_fwd.hpp.

◆ cend()

template<typename Scalar , int dimension>
const Scalar* mm::VectorField< Scalar, dimension >::cend ( ) const
inline

Const version of end.

Definition at line 144 of file VectorField_fwd.hpp.

◆ end() [1/2]

template<typename Scalar , int dimension>
Scalar* mm::VectorField< Scalar, dimension >::end ( )
inline

Pointer to the last coefficient.

Definition at line 137 of file VectorField_fwd.hpp.

◆ end() [2/2]

template<typename Scalar , int dimension>
const Scalar* mm::VectorField< Scalar, dimension >::end ( ) const
inline

Const pointer to the last coefficient.

Definition at line 139 of file VectorField_fwd.hpp.

◆ fromLinear()

template<typename Scalar , int dimension>
template<typename OtherDerived >
static VectorField mm::VectorField< Scalar, dimension >::fromLinear ( const Eigen::PlainObjectBase< OtherDerived > &  other)
static

Construct VectorField from its linear representation, obtained from asLinear().

Examples
test/types/VectorField_test.cpp.

◆ operator()() [1/3]

template<typename Scalar , int dimension>
Eigen::IndexedView<Base, indexes_t, Eigen::internal::AllRange<dimension> > SINL mm::VectorField< Scalar, dimension >::operator() ( const indexes_t rowIndices)
inline

Return an indexed view to a subset of vectors.

Definition at line 122 of file VectorField_fwd.hpp.

◆ operator()() [2/3]

template<typename Scalar , int dimension>
SINL Eigen::Transpose<typename Base::RowXpr> mm::VectorField< Scalar, dimension >::operator() ( typename Eigen::Index  i)
inline

Return a single row as a vector, non-const version.

Definition at line 104 of file VectorField_fwd.hpp.

◆ operator()() [3/3]

template<typename Scalar , int dimension>
SINL Eigen::Transpose<typename Base::ConstRowXpr> mm::VectorField< Scalar, dimension >::operator() ( typename Eigen::Index  i) const
inline

Return a single row as a vector, const version.

Definition at line 108 of file VectorField_fwd.hpp.

◆ operator=() [1/4]

template<typename Scalar , int dimension>
template<typename OtherDerived >
VectorField& mm::VectorField< Scalar, dimension >::operator= ( const Eigen::MatrixBase< OtherDerived > &  other)

Assignments of Eigen expressions to VectorField.

◆ operator=() [2/4]

template<typename Scalar , int dimension>
VectorField< Scalar, dimension > & mm::VectorField< Scalar, dimension >::operator= ( const Vec< Scalar, dimension > &  v)

Assigns vector field to be a constant vector v.

Definition at line 29 of file VectorField.hpp.

◆ operator=() [3/4]

template<typename Scalar , int dimension>
VectorField& mm::VectorField< Scalar, dimension >::operator= ( const VectorField< Scalar, dimension > &  )
default

Default copy assignment.

◆ operator=() [4/4]

template<typename Scalar , int dimension>
VectorField& mm::VectorField< Scalar, dimension >::operator= ( VectorField< Scalar, dimension > &&  )
defaultnoexcept

Default move assignment.

◆ operator[]() [1/3]

template<typename Scalar , int dimension>
SINL VectorFieldView mm::VectorField< Scalar, dimension >::operator[] ( const indexes_t indexes)
inline

Returns an indexed view to a subset of vectors, that can be assigned.

Definition at line 127 of file VectorField_fwd.hpp.

◆ operator[]() [2/3]

template<typename Scalar , int dimension>
Eigen::Transpose<typename Base::RowXpr> mm::VectorField< Scalar, dimension >::operator[] ( typename Eigen::Index  i)
inline

Return a single row as a vector, non-const version.

Definition at line 94 of file VectorField_fwd.hpp.

◆ operator[]() [3/3]

template<typename Scalar , int dimension>
SINL Eigen::Transpose<typename Base::ConstRowXpr> mm::VectorField< Scalar, dimension >::operator[] ( typename Eigen::Index  i) const
inline

Return a single row as a vector, const version.

Definition at line 98 of file VectorField_fwd.hpp.


The documentation for this class was generated from the following files:
mm::VectorField::c
SINL Base::ColXpr c(typename Eigen::Index i)
Return the i-th component of this vector field.
Definition: VectorField_fwd.hpp:116
mm::VectorField::fromLinear
static VectorField fromLinear(const Eigen::PlainObjectBase< OtherDerived > &other)
Construct VectorField from its linear representation, obtained from asLinear().
mm::VectorField3d
VectorField< double, 3 > VectorField3d
Three dimensional vector field of doubles.
Definition: VectorField_fwd.hpp:153
mm::VectorField2d
VectorField< double, 2 > VectorField2d
Two dimensional vector field of doubles.
Definition: VectorField_fwd.hpp:152
mm::Vec2d
Vec< double, 2 > Vec2d
Convenience typedef for 2d vector of doubles.
Definition: Vec_fwd.hpp:34