Drake
Drake C++ Documentation
Loading...
Searching...
No Matches
Subvector< T > Class Template Referencefinal

Detailed Description

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

Subvector is a concrete class template that implements VectorBase by providing a sliced view of a VectorBase.

Template Parameters
TThe scalar type, which must be one of the default scalars.

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

Public Member Functions

 Subvector (VectorBase< T > *vector, int first_element, int num_elements)
 Constructs a subvector of vector that consists of num_elements starting at first_element.
int size () const final
 Returns the number of elements in the vector.
Does not allow copy, move, or assignment
 Subvector (const Subvector &)=delete
Subvectoroperator= (const Subvector &)=delete
 Subvector (Subvector &&)=delete
Subvectoroperator= (Subvector &&)=delete
Public Member Functions inherited from VectorBase< T >
virtual ~VectorBase ()
T & operator[] (int index)
 Returns the element at the given index in the vector.
const T & operator[] (int index) const
 Returns the element at the given index in the vector.
const T & GetAtIndex (int index) const
 Returns the element at the given index in the vector.
T & GetAtIndex (int index)
 Returns the element at the given index in the vector.
void SetAtIndex (int index, const T &value)
 Replaces the state at the given index with the value.
virtual void SetFrom (const VectorBase< T > &value)
 Replaces the entire vector with the contents of value.
virtual void SetFromVector (const Eigen::Ref< const VectorX< T > > &value)
 Replaces the entire vector with the contents of value.
virtual void SetZero ()
 Sets all elements of this vector to zero.
virtual VectorX< T > CopyToVector () const
 Copies this entire VectorBase into a contiguous Eigen Vector.
virtual void CopyToPreSizedVector (EigenPtr< VectorX< T > > vec) const
 Copies this entire VectorBase into a pre-sized Eigen Vector.
virtual void ScaleAndAddToVector (const T &scale, EigenPtr< VectorX< T > > vec) const
 Adds a scaled version of this vector to Eigen vector vec.
VectorBasePlusEqScaled (const T &scale, const VectorBase< T > &rhs)
 Add in scaled vector rhs to this vector.
VectorBasePlusEqScaled (const std::initializer_list< std::pair< T, const VectorBase< T > & > > &rhs_scale)
 Add in multiple scaled vectors to this vector.
VectorBaseoperator+= (const VectorBase< T > &rhs)
 Add in vector rhs to this vector.
VectorBaseoperator-= (const VectorBase< T > &rhs)
 Subtract in vector rhs to this vector.
virtual void GetElementBounds (Eigen::VectorXd *lower, Eigen::VectorXd *upper) const
 Get the bounds for the elements.
 VectorBase (const VectorBase &)=delete
VectorBaseoperator= (const VectorBase &)=delete
 VectorBase (VectorBase &&)=delete
VectorBaseoperator= (VectorBase &&)=delete

Additional Inherited Members

Protected Member Functions inherited from VectorBase< T >
 VectorBase ()
virtual void DoPlusEqScaled (const std::initializer_list< std::pair< T, const VectorBase< T > & > > &rhs_scale)
 Adds in multiple scaled vectors to this vector.
void ThrowOutOfRange (int index) const
void ThrowMismatchedSize (int other_size) const

Constructor & Destructor Documentation

◆ Subvector() [1/3]

template<typename T>
Subvector ( const Subvector< T > & )
delete

◆ Subvector() [2/3]

template<typename T>
Subvector ( Subvector< T > && )
delete

◆ Subvector() [3/3]

template<typename T>
Subvector ( VectorBase< T > * vector,
int first_element,
int num_elements )

Constructs a subvector of vector that consists of num_elements starting at first_element.

Parameters
vectorThe vector to slice. Must not be nullptr. Must remain valid for the lifetime of this object.

Member Function Documentation

◆ operator=() [1/2]

template<typename T>
Subvector & operator= ( const Subvector< T > & )
delete

◆ operator=() [2/2]

template<typename T>
Subvector & operator= ( Subvector< T > && )
delete

◆ size()

template<typename T>
int size ( ) const
finalvirtual

Returns the number of elements in the vector.

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

Implements VectorBase< T >.


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