Represents a symbolic environment (mapping from a variable to a value).
This class is used when we evaluate symbolic expressions or formulas which include unquantified (free) variables. Here are examples:
#include <drake/common/symbolic/expression/environment.h>
Public Types | |
typedef Variable | key_type |
typedef double | mapped_type |
typedef std::unordered_map< key_type, mapped_type > | map |
typedef map::value_type | value_type |
std::pair<key_type, mapped_type> More... | |
typedef map::iterator | iterator |
typedef map::const_iterator | const_iterator |
Public Member Functions | |
Environment ()=default | |
Default constructor. More... | |
Environment (std::initializer_list< value_type > init) | |
List constructor. More... | |
Environment (std::initializer_list< key_type > vars) | |
List constructor. More... | |
Environment (map m) | |
Constructs an environment from m (of map type, which is std::unordered_map ). More... | |
~Environment () | |
iterator | begin () |
Returns an iterator to the beginning. More... | |
iterator | end () |
Returns an iterator to the end. More... | |
const_iterator | begin () const |
Returns a const iterator to the beginning. More... | |
const_iterator | end () const |
Returns a const iterator to the end. More... | |
const_iterator | cbegin () const |
Returns a const iterator to the beginning. More... | |
const_iterator | cend () const |
Returns a const iterator to the end. More... | |
void | insert (const key_type &key, const mapped_type &elem) |
Inserts a pair (key , elem ) if this environment doesn't contain key . More... | |
void | insert (const Eigen::Ref< const MatrixX< key_type >> &keys, const Eigen::Ref< const MatrixX< mapped_type >> &elements) |
Given a matrix of symbolic variables keys and a matrix of values elements , inserts each pair (keys(i, j), elements(i, j)) into the environment if this environment doesn't contain keys(i, j) . More... | |
bool | empty () const |
Checks whether the container is empty. More... | |
size_t | size () const |
Returns the number of elements. More... | |
iterator | find (const key_type &key) |
Finds element with specific key. More... | |
const_iterator | find (const key_type &key) const |
Finds element with specific key. More... | |
Variables | domain () const |
Returns the domain of this environment. More... | |
std::string | to_string () const |
Returns string representation. More... | |
mapped_type & | operator[] (const key_type &key) |
Returns a reference to the value that is mapped to a key equivalent to key , performing an insertion if such key does not already exist. More... | |
const mapped_type & | operator[] (const key_type &key) const |
As above, but returns a constref and does not perform an insertion (throwing a runtime error instead) if the key does not exist. More... | |
Implements CopyConstructible, CopyAssignable, MoveConstructible, MoveAssignable | |
Environment (const Environment &)=default | |
Environment & | operator= (const Environment &)=default |
Environment (Environment &&)=default | |
Environment & | operator= (Environment &&)=default |
Friends | |
std::ostream & | operator<< (std::ostream &os, const Environment &env) |
typedef map::const_iterator const_iterator |
typedef map::iterator iterator |
typedef std::unordered_map<key_type, mapped_type> map |
typedef double mapped_type |
typedef map::value_type value_type |
std::pair<key_type, mapped_type>
|
default |
|
default |
|
default |
Default constructor.
Environment | ( | std::initializer_list< value_type > | init | ) |
List constructor.
Constructs an environment from a list of (Variable * double).
std::exception | if init include a dummy variable or a NaN value. |
Environment | ( | std::initializer_list< key_type > | vars | ) |
List constructor.
Constructs an environment from a list of Variable. Initializes the variables with 0.0.
std::exception | if vars include a dummy variable. |
|
explicit |
Constructs an environment from m
(of map
type, which is std::unordered_map
).
std::exception | if m include a dummy variable or a NaN value. |
~Environment | ( | ) |
iterator begin | ( | ) |
Returns an iterator to the beginning.
const_iterator begin | ( | ) | const |
Returns a const iterator to the beginning.
const_iterator cbegin | ( | ) | const |
Returns a const iterator to the beginning.
const_iterator cend | ( | ) | const |
Returns a const iterator to the end.
Variables domain | ( | ) | const |
Returns the domain of this environment.
bool empty | ( | ) | const |
Checks whether the container is empty.
iterator end | ( | ) |
Returns an iterator to the end.
const_iterator end | ( | ) | const |
Returns a const iterator to the end.
const_iterator find | ( | const key_type & | key | ) | const |
Finds element with specific key.
void insert | ( | const key_type & | key, |
const mapped_type & | elem | ||
) |
Inserts a pair (key
, elem
) if this environment doesn't contain key
.
Similar to insert function in map, if the key already exists in this environment, then calling insert(key, elem) doesn't change the existing key-value in this environment.
void insert | ( | const Eigen::Ref< const MatrixX< key_type >> & | keys, |
const Eigen::Ref< const MatrixX< mapped_type >> & | elements | ||
) |
Given a matrix of symbolic variables keys
and a matrix of values elements
, inserts each pair (keys(i, j), elements(i, j)) into the environment if this environment doesn't contain keys(i, j) .
Similar to insert function in map, if keys(i, j) already exists in this environment, then this function doesn't change the its existing value in this environment.
std::exception | if the size of keys is different from the size of elements . |
|
default |
|
default |
mapped_type& operator[] | ( | const key_type & | key | ) |
Returns a reference to the value that is mapped to a key equivalent to key
, performing an insertion if such key does not already exist.
const mapped_type& operator[] | ( | const key_type & | key | ) | const |
As above, but returns a constref and does not perform an insertion (throwing a runtime error instead) if the key does not exist.
size_t size | ( | ) | const |
Returns the number of elements.
std::string to_string | ( | ) | const |
Returns string representation.
|
friend |