28 virtual int size()
const = 0;
35 virtual const T
GetAtIndex(
int index)
const = 0;
42 virtual void SetAtIndex(
int index,
const T& value) = 0;
66 if (vec.rows() !=
size()) {
67 throw std::out_of_range(
"Addends must be the same length.");
69 for (
int i = 0; i <
size(); ++i)
82 throw std::out_of_range(
"Addends must be the same length.");
84 for (
int i = 0; i <
size(); ++i)
virtual int size() const =0
Returns the number of elements in the vector.
Definition: constants.h:3
StateVector is an abstract base class template for vector quantities within the state of a System...
Definition: state_vector.h:20
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > VectorX
A column vector of any size, templated on scalar type.
Definition: eigen_types.h:36
StateVector()
Definition: state_vector.h:100
virtual void SetAtIndex(int index, const T &value)=0
Replaces the state at the given index with the value.
Provides Drake's assertion implementation.
StateVector & operator-=(const StateVector< T > &rhs)
Subtract in state vector rhs to this state vector.
Definition: state_vector.h:95
virtual const T GetAtIndex(int index) const =0
Returns the element at the given index in the vector.
virtual StateVector & PlusEqScaled(const T &scale, const StateVector< T > &rhs)
Add in scaled state vector rhs to this state vector.
Definition: state_vector.h:80
virtual void ScaleAndAddToVector(const T &scale, Eigen::Ref< VectorX< T >> vec) const
Adds a scaled version of this state vector to Eigen vector vec, which must be the same size...
Definition: state_vector.h:64
virtual VectorX< T > CopyToVector() const =0
Copies the entire state to a vector with no semantics.
virtual void SetFromVector(const Eigen::Ref< const VectorX< T >> &value)=0
Replaces the entire state with the contents of value.
StateVector & operator+=(const StateVector< T > &rhs)
Add in state vector rhs to this state vector.
Definition: state_vector.h:90
virtual ~StateVector()
Definition: state_vector.h:22