Drake
VectorBase< T > Class Template Referenceabstract

VectorBase is an abstract base class that real-valued signals between Systems and real-valued System state vectors must implement. More...

#include <drake/systems/framework/vector_base.h>

Inheritance diagram for VectorBase< T >:
[legend]

Public Member Functions

virtual ~VectorBase ()
 
virtual int size () const =0
 Returns the number of elements in the vector. More...
 
virtual const T & GetAtIndex (int index) const =0
 Returns the element at the given index in the vector. More...
 
virtual T & GetAtIndex (int index)=0
 Returns the element at the given index in the vector. More...
 
T & operator[] (std::size_t idx)
 
const T & operator[] (std::size_t idx) const
 
void SetAtIndex (int index, const T &value)
 Replaces the state at the given index with the value. More...
 
virtual void SetFrom (const VectorBase< T > &value)
 Replaces the entire vector with the contents of value. More...
 
virtual void SetFromVector (const Eigen::Ref< const VectorX< T >> &value)
 Replaces the entire vector with the contents of value. More...
 
virtual void SetZero ()
 
virtual VectorX< T > CopyToVector () const
 Copies the entire state to a vector with no semantics. More...
 
virtual void ScaleAndAddToVector (const T &scale, Eigen::Ref< VectorX< T >> vec) const
 Adds a scaled version of this vector to Eigen vector vec, which must be the same size. More...
 
VectorBasePlusEqScaled (const T &scale, const VectorBase< T > &rhs)
 Add in scaled vector rhs to this vector. More...
 
VectorBasePlusEqScaled (const std::initializer_list< std::pair< T, const VectorBase< T > & >> &rhs_scale)
 Add in multiple scaled vectors to this vector. More...
 
VectorBaseoperator+= (const VectorBase< T > &rhs)
 Add in vector rhs to this vector. More...
 
VectorBaseoperator-= (const VectorBase< T > &rhs)
 Subtract in vector rhs to this vector. More...
 
virtual T NormInf () const
 Computes the infinity norm for this vector. More...
 
virtual void CalcInequalityConstraint (VectorX< T > *value) const
 Populates a vector value suitable for a SystemConstraint inequality constraint. More...
 
Does not allow copy, move, or assignment
 VectorBase (const VectorBase &)=delete
 
VectorBaseoperator= (const VectorBase &)=delete
 
 VectorBase (VectorBase &&)=delete
 
VectorBaseoperator= (VectorBase &&)=delete
 

Protected Member Functions

 VectorBase ()
 
virtual void DoPlusEqScaled (const std::initializer_list< std::pair< T, const VectorBase< T > & >> &rhs_scale)
 Adds in multiple scaled vectors to this vector. More...
 

Detailed Description

template<typename T>
class drake::systems::VectorBase< T >

VectorBase is an abstract base class that real-valued signals between Systems and real-valued System state vectors must implement.

Classes that inherit from VectorBase will typically provide names for the elements of the vector, and may also provide other computations for the convenience of Systems handling the signal. The vector is always a column vector. It may or may not be contiguous in memory. Contiguous subclasses should typically inherit from BasicVector, not from VectorBase directly.

Template Parameters
TMust be a Scalar compatible with Eigen.

Constructor & Destructor Documentation

VectorBase ( const VectorBase< T > &  )
delete
VectorBase ( VectorBase< T > &&  )
delete
virtual ~VectorBase ( )
inlinevirtual
VectorBase ( )
inlineprotected

Member Function Documentation

virtual void CalcInequalityConstraint ( VectorX< T > *  value) const
inlinevirtual

Populates a vector value suitable for a SystemConstraint inequality constraint.

For all indices i in the result vector, the validity constraint is result[i] >= 0. For a given subclass type, the size of the result must not vary over time. The VectorBase default implementation sets the value to be empty (no constraints).

Reimplemented in Sample< T >.

Here is the caller graph for this function:

virtual VectorX<T> CopyToVector ( ) const
inlinevirtual

Copies the entire state to a vector with no semantics.

Implementations should ensure this operation is O(N) in the size of the value and allocates only the O(N) memory that it returns.

Reimplemented in BasicVector< T >, BasicVector< double >, BasicVector< AutoDiffXd >, and BasicVector< symbolic::Expression >.

Here is the caller graph for this function:

virtual void DoPlusEqScaled ( const std::initializer_list< std::pair< T, const VectorBase< T > & >> &  rhs_scale)
inlineprotectedvirtual

Adds in multiple scaled vectors to this vector.

All vectors are guaranteed to be the same size.

You should override this method if possible with a more efficient approach that leverages structure; the default implementation performs element-by-element computations that are likely inefficient, but even this implementation minimizes memory accesses for efficiency. If the vector is contiguous, for example, implementations that leverage SIMD operations should be far more efficient. Overriding implementations should ensure that this operation remains O(N) in the size of the value and allocates no memory.

Here is the caller graph for this function:

virtual const T& GetAtIndex ( int  index) const
pure virtual

Returns the element at the given index in the vector.

Throws std::runtime_error if the index is >= size().

Implementations should ensure this operation is O(1) and allocates no memory.

Implemented in BasicVector< T >, BasicVector< double >, BasicVector< AutoDiffXd >, BasicVector< symbolic::Expression >, Subvector< T >, and Supervector< T >.

Here is the caller graph for this function:

virtual T& GetAtIndex ( int  index)
pure virtual

Returns the element at the given index in the vector.

Throws std::runtime_error if the index is >= size().

Implementations should ensure this operation is O(1) and allocates no memory.

Implemented in BasicVector< T >, BasicVector< double >, BasicVector< AutoDiffXd >, BasicVector< symbolic::Expression >, Subvector< T >, and Supervector< T >.

virtual T NormInf ( ) const
inlinevirtual

Computes the infinity norm for this vector.

You should override this method if possible with a more efficient approach that leverages structure; the default implementation performs element-by-element computations that are likely inefficient. If the vector is contiguous, for example, Eigen implementations should be far more efficient. Overriding implementations should ensure that this operation remains O(N) in the size of the value and allocates no memory.

Reimplemented in BasicVector< T >, BasicVector< double >, BasicVector< AutoDiffXd >, and BasicVector< symbolic::Expression >.

VectorBase& operator+= ( const VectorBase< T > &  rhs)
inline

Add in vector rhs to this vector.

VectorBase& operator-= ( const VectorBase< T > &  rhs)
inline

Subtract in vector rhs to this vector.

VectorBase& operator= ( VectorBase< T > &&  )
delete
VectorBase& operator= ( const VectorBase< T > &  )
delete
T& operator[] ( std::size_t  idx)
inline
const T& operator[] ( std::size_t  idx) const
inline
VectorBase& PlusEqScaled ( const T &  scale,
const VectorBase< T > &  rhs 
)
inline

Add in scaled vector rhs to this vector.

Both vectors must be the same size.

Here is the caller graph for this function:

VectorBase& PlusEqScaled ( const std::initializer_list< std::pair< T, const VectorBase< T > & >> &  rhs_scale)
inline

Add in multiple scaled vectors to this vector.

All vectors must be the same size.

virtual void ScaleAndAddToVector ( const T &  scale,
Eigen::Ref< VectorX< T >>  vec 
) const
inlinevirtual

Adds a scaled version of this vector to Eigen vector vec, which must be the same size.

Implementations may override this default implementation with a more efficient approach, for instance if this vector is contiguous. Implementations should ensure this operation remains O(N) in the size of the value and allocates no memory.

Reimplemented in BasicVector< T >, BasicVector< double >, BasicVector< AutoDiffXd >, and BasicVector< symbolic::Expression >.

void SetAtIndex ( int  index,
const T &  value 
)
inline

Replaces the state at the given index with the value.

Throws std::runtime_error if the index is >= size().

Here is the caller graph for this function:

virtual void SetFrom ( const VectorBase< T > &  value)
inlinevirtual

Replaces the entire vector with the contents of value.

Throws std::runtime_error if value is not a column vector with size() rows.

Implementations should ensure this operation is O(N) in the size of the value and allocates no memory.

Here is the caller graph for this function:

virtual void SetFromVector ( const Eigen::Ref< const VectorX< T >> &  value)
inlinevirtual

Replaces the entire vector with the contents of value.

Throws std::runtime_error if value is not a column vector with size() rows.

Implementations should ensure this operation is O(N) in the size of the value and allocates no memory.

Reimplemented in BasicVector< T >, BasicVector< double >, BasicVector< AutoDiffXd >, and BasicVector< symbolic::Expression >.

Here is the caller graph for this function:

virtual void SetZero ( )
inlinevirtual
virtual int size ( ) const
pure virtual

Returns the number of elements in the vector.

Implementations should ensure this operation is O(1) and allocates no memory.

Implemented in BasicVector< T >, BasicVector< double >, BasicVector< AutoDiffXd >, BasicVector< symbolic::Expression >, Subvector< T >, and Supervector< T >.

Here is the caller graph for this function:


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