TVM
0.9.2
|
#include <tvm/Variable.h>
Public Member Functions | |
Variable (const Variable &)=delete | |
Variable & | operator= (const Variable &)=delete |
~Variable () | |
VariablePtr | duplicate (std::string_view name="") const |
const std::string & | name () const |
int | size () const |
const Space & | space () const |
const Space & | spaceShift () const |
bool | isEuclidean () const |
VectorConstRef | value () const |
TVM_DEPRECATED void | value (const VectorConstRef &x) |
void | set (const VectorConstRef &x) |
void | set (Eigen::DenseIndex idx, double value) |
void | set (Eigen::DenseIndex idx, Eigen::DenseIndex length, const VectorConstRef &value) |
void | setZero () |
int | derivativeNumber () const |
bool | isDerivativeOf (const Variable &v) const |
bool | isPrimitiveOf (const Variable &v) const |
bool | isBasePrimitive () const |
template<int n = 1> | |
VariablePtr | primitive () const |
VariablePtr | basePrimitive () const |
bool | isSubvariable () const |
VariablePtr | superVariable () const |
bool | isSuperVariable () const |
bool | isSuperVariableOf (const Variable &v) const |
Range | subvariableRange () const |
Range | tSubvariableRange () const |
bool | contains (const Variable &v) const |
bool | intersects (const Variable &v) const |
VariablePtr | subvariable (Space space, std::string_view baseName, Space shift={0}) const |
VariablePtr | subvariable (Space space, Space shift={0}) const |
Range | getMappingIn (const VariableVector &variables) const |
VariablePtr | shared_from_this () |
Eigen::CommaInitializer< VectorRef > | operator<< (double d) |
template<typename Derived > | |
Eigen::CommaInitializer< VectorRef > | operator<< (const Eigen::DenseBase< Derived > &other) |
Variable (make_shared_token, VariablePtr var, const Space &space, std::string_view name, const Space &shift) | |
Public Member Functions inherited from tvm::internal::ObjWithId | |
ObjWithId (const ObjWithId &)=delete | |
ObjWithId (ObjWithId &&other) | |
ObjWithId & | operator= (const ObjWithId &)=delete |
ObjWithId & | operator= (ObjWithId &&other) |
int | id () const |
Friends | |
class | Space |
class | VariableVector |
bool | operator== (const Variable &u, const Variable &v) |
bool | operator!= (const Variable &u, const Variable &v) |
VariablePtr TVM_DLLAPI | dot (VariablePtr, int, bool) |
Additional Inherited Members | |
Protected Member Functions inherited from tvm::internal::ObjWithId | |
ObjWithId () | |
Representation of a Variable, i.e. a point in a space.
A variable can only be constructed from a Space, in which case we say it is a base primitive, or from an other variable, by derivation with the dot() operator.
A variables can be a subvariable, i.e. a contiguous subpart of an other variable.
|
delete |
Copying variables is illicit. To get a different variable with the same characteristics, see duplicate.
tvm::Variable::~Variable | ( | ) |
Destructor.
tvm::Variable::Variable | ( | make_shared_token | , |
VariablePtr | var, | ||
const Space & | space, | ||
std::string_view | name, | ||
const Space & | shift | ||
) |
Constructor for a subvariable of var
VariablePtr tvm::Variable::basePrimitive | ( | ) | const |
Get the base primitive of this variable. Equivalent to primitive<d>() where d = derivativeNumber().
bool tvm::Variable::contains | ( | const Variable & | v | ) | const |
Return true if v
is a sub-part of this variable.
To the difference of Variable::isSuperVariableOf, it is sufficient that both this variable and v
have the same supervariable. This variable does not need to be a supervariable itself.
int tvm::Variable::derivativeNumber | ( | ) | const |
If this variable is a base primitive (i.e. built from a space), return 0. Otherwise, return the number of time a base primitive variable had to be derived to get to this variable.
VariablePtr tvm::Variable::duplicate | ( | std::string_view | name = "" | ) | const |
Create a variable based on the same space, with the same derivative number and value.
name | the name of the new variable. If the default value is kept, a ' will be appended to the current name. If the variable being duplicated is not a base variable, the name is given to the base variable. |
Range tvm::Variable::getMappingIn | ( | const VariableVector & | variables | ) | const |
Get the mapping of this variable, within a vector of variables: if all variables values are stacked in one vector v, the returned Range specifies the segment of v corresponding to this variable.
bool tvm::Variable::intersects | ( | const Variable & | v | ) | const |
Return this variable and v both contain the same subpart of a variable.
bool tvm::Variable::isBasePrimitive | ( | ) | const |
Return true if this variable is a base primitive (derivativeNumber() == 0), false otherwise.
bool tvm::Variable::isDerivativeOf | ( | const Variable & | v | ) | const |
Check if this variable is a derivative of v
This is in a strict sense: v.isDerivativeOf(v) si false.
bool tvm::Variable::isEuclidean | ( | ) | const |
Check if the variable lives in a Euclidean space. Pay attention that for a variable v, v.isEuclidean() is not necessarily equal to v.space().isEuclidean(): if v is a derivative of a variable linked to a non-Euclidean space, it lives in the tangent space which is Euclidean.
bool tvm::Variable::isPrimitiveOf | ( | const Variable & | v | ) | const |
Check if this variable is a primitive of v
This is in a strict sense: v.isPrimitiveOf(v) si false.
bool tvm::Variable::isSubvariable | ( | ) | const |
Return whether or not this variable is the subvariable of another variable.
bool tvm::Variable::isSuperVariable | ( | ) | const |
Return true if this variable is not the subvariable of any other variable.
bool tvm::Variable::isSuperVariableOf | ( | const Variable & | v | ) | const |
Return true if v
is a subvariable of this variable and this variable is a supervariable.
The requirement that this variable is a supervariable makes it different from Variable::contains.
const std::string& tvm::Variable::name | ( | ) | const |
Return the name of the variable
|
inline |
Helper to initialize a variable like an Eigen vector.
|
inline |
Helper to initialize a variable like an Eigen vector.
Copying variables is illicit. To get a different variable with the same characteristics, see duplicate.
|
inline |
Get the n-th primitive of the variable
void tvm::Variable::set | ( | const VectorConstRef & | x | ) |
Set the value of the variable.
void tvm::Variable::set | ( | Eigen::DenseIndex | idx, |
double | value | ||
) |
Set the value at idx
to value
void tvm::Variable::set | ( | Eigen::DenseIndex | idx, |
Eigen::DenseIndex | length, | ||
const VectorConstRef & | value | ||
) |
Set the value of a block of length length
starting at idx
to the value in value
void tvm::Variable::setZero | ( | ) |
Set the value of the variable to 0
VariablePtr tvm::Variable::shared_from_this | ( | ) |
Overload of enable_shared_from_this::shared_from_this, for technical purpose.
int tvm::Variable::size | ( | ) | const |
Return the size of the variable, i.e. the size of the vector needed to represent it.
const Space& tvm::Variable::space | ( | ) | const |
Return the space to which this variable is linked. It is either the space the variable was obtained from (for a variable that is a primitive), or the space of its primitive (for a variable which is derived from an other).
const Space& tvm::Variable::spaceShift | ( | ) | const |
Return the space of the subvariable preceding this variable w.r.t its supervariable. E.g if this variable is x, and is a subvariable of X such that X = (u, x, y), x->spaceShift() corresponds to u->space().
VariablePtr tvm::Variable::subvariable | ( | Space | space, |
Space | shift = {0} |
||
) | const |
Create a subvariable
space | The space in which the variable (or its base primitive in case of a derivative) is a point. |
shift | The space of the subvariable before this subvariable w.r.t the current variable. For example x->subVariable (Space(3), "y", Space(2)) creates a subvariable y of x starting after the two first element (x0, x1) and containing the three elements (x2,x3,x4). This shift is with respect to the space of the supervariable. This is important if it is not Euclidean. |
Name is automatically generated as xstart:end for a k-th derivative.
VariablePtr tvm::Variable::subvariable | ( | Space | space, |
std::string_view | baseName, | ||
Space | shift = {0} |
||
) | const |
Create a subvariable
space | The space in which the variable (or its base primitive in case of a derivative) is a point. |
baseName | The name of the variable or its base primitive (if different). |
shift | The space of the subvariable before this subvariable w.r.t the current variable. For example x->subVariable (Space(3), "y", Space(2)) creates a subvariable y of x starting after the two first element (x0, x1) and containing the three elements (x2,x3,x4). This shift is with respect to the space of the supervariable. This is important if it is not Euclidean. |
Range tvm::Variable::subvariableRange | ( | ) | const |
If this variable is a subvariable, return its range within its supevariable. If not, simply return [0, size()].
VariablePtr tvm::Variable::superVariable | ( | ) | const |
If this variable is a subvariable, return the variable it is a subvariable of. Otherwise, return this variable.
Range tvm::Variable::tSubvariableRange | ( | ) | const |
Equivalent to dot(this)->subvariableRange (without having to create the derivative).
VectorConstRef tvm::Variable::value | ( | ) | const |
Return the current value of the variable.
|
inline |
(DEPRECATED) Set the value of the variable.
|
friend |
Get the ndiff-th time derivative of a variable
var | the variable to be derived |
ndiff | the order of the derivation |
autoName | base the name on that of the supervariable of the primitive (if the variable was not already created with another name before). |
|
friend |
friendship declaration
|
friend |