TVM  0.9.2
tvm::Variable Class Reference

#include <tvm/Variable.h>

Inheritance diagram for tvm::Variable:
Collaboration diagram for tvm::Variable:

Public Member Functions

 Variable (const Variable &)=delete
 
Variableoperator= (const Variable &)=delete
 
 ~Variable ()
 
VariablePtr duplicate (std::string_view name="") const
 
const std::string & name () const
 
int size () const
 
const Spacespace () const
 
const SpacespaceShift () 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< VectorRefoperator<< (double d)
 
template<typename Derived >
Eigen::CommaInitializer< VectorRefoperator<< (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)
 
ObjWithIdoperator= (const ObjWithId &)=delete
 
ObjWithIdoperator= (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 ()
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Variable() [1/2]

tvm::Variable::Variable ( const Variable )
delete

Copying variables is illicit. To get a different variable with the same characteristics, see duplicate.

◆ ~Variable()

tvm::Variable::~Variable ( )

Destructor.

◆ Variable() [2/2]

tvm::Variable::Variable ( make_shared_token  ,
VariablePtr  var,
const Space space,
std::string_view  name,
const Space shift 
)

Constructor for a subvariable of var

Member Function Documentation

◆ basePrimitive()

VariablePtr tvm::Variable::basePrimitive ( ) const

Get the base primitive of this variable. Equivalent to primitive<d>() where d = derivativeNumber().

◆ contains()

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.

◆ derivativeNumber()

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.

◆ duplicate()

VariablePtr tvm::Variable::duplicate ( std::string_view  name = "") const

Create a variable based on the same space, with the same derivative number and value.

Parameters
namethe 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.

◆ getMappingIn()

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.

◆ intersects()

bool tvm::Variable::intersects ( const Variable v) const

Return this variable and v both contain the same subpart of a variable.

◆ isBasePrimitive()

bool tvm::Variable::isBasePrimitive ( ) const

Return true if this variable is a base primitive (derivativeNumber() == 0), false otherwise.

◆ isDerivativeOf()

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.

◆ isEuclidean()

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.

◆ isPrimitiveOf()

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.

◆ isSubvariable()

bool tvm::Variable::isSubvariable ( ) const

Return whether or not this variable is the subvariable of another variable.

◆ isSuperVariable()

bool tvm::Variable::isSuperVariable ( ) const

Return true if this variable is not the subvariable of any other variable.

◆ isSuperVariableOf()

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.

◆ name()

const std::string& tvm::Variable::name ( ) const

Return the name of the variable

◆ operator<<() [1/2]

template<typename Derived >
Eigen::CommaInitializer< VectorRef > tvm::Variable::operator<< ( const Eigen::DenseBase< Derived > &  other)
inline

Helper to initialize a variable like an Eigen vector.

◆ operator<<() [2/2]

Eigen::CommaInitializer< VectorRef > tvm::Variable::operator<< ( double  d)
inline

Helper to initialize a variable like an Eigen vector.

◆ operator=()

Variable& tvm::Variable::operator= ( const Variable )
delete

Copying variables is illicit. To get a different variable with the same characteristics, see duplicate.

◆ primitive()

template<int n>
VariablePtr tvm::Variable::primitive
inline

Get the n-th primitive of the variable

◆ set() [1/3]

void tvm::Variable::set ( const VectorConstRef x)

Set the value of the variable.

◆ set() [2/3]

void tvm::Variable::set ( Eigen::DenseIndex  idx,
double  value 
)

Set the value at idx to value

◆ set() [3/3]

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

◆ setZero()

void tvm::Variable::setZero ( )

Set the value of the variable to 0

◆ shared_from_this()

VariablePtr tvm::Variable::shared_from_this ( )

Overload of enable_shared_from_this::shared_from_this, for technical purpose.

◆ size()

int tvm::Variable::size ( ) const

Return the size of the variable, i.e. the size of the vector needed to represent it.

◆ space()

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).

◆ spaceShift()

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().

◆ subvariable() [1/2]

VariablePtr tvm::Variable::subvariable ( Space  space,
Space  shift = {0} 
) const

Create a subvariable

Parameters
spaceThe space in which the variable (or its base primitive in case of a derivative) is a point.
shiftThe 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.

◆ subvariable() [2/2]

VariablePtr tvm::Variable::subvariable ( Space  space,
std::string_view  baseName,
Space  shift = {0} 
) const

Create a subvariable

Parameters
spaceThe space in which the variable (or its base primitive in case of a derivative) is a point.
baseNameThe name of the variable or its base primitive (if different).
shiftThe 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.

◆ subvariableRange()

Range tvm::Variable::subvariableRange ( ) const

If this variable is a subvariable, return its range within its supevariable. If not, simply return [0, size()].

◆ superVariable()

VariablePtr tvm::Variable::superVariable ( ) const

If this variable is a subvariable, return the variable it is a subvariable of. Otherwise, return this variable.

◆ tSubvariableRange()

Range tvm::Variable::tSubvariableRange ( ) const

Equivalent to dot(this)->subvariableRange (without having to create the derivative).

◆ value() [1/2]

VectorConstRef tvm::Variable::value ( ) const

Return the current value of the variable.

◆ value() [2/2]

TVM_DEPRECATED void tvm::Variable::value ( const VectorConstRef x)
inline

(DEPRECATED) Set the value of the variable.

Friends And Related Function Documentation

◆ dot

VariablePtr TVM_DLLAPI dot ( VariablePtr  ,
int  ,
bool   
)
friend

Get the ndiff-th time derivative of a variable

Parameters
varthe variable to be derived
ndiffthe order of the derivation
autoNamebase the name on that of the supervariable of the primitive (if the variable was not already created with another name before).

◆ operator!=

bool operator!= ( const Variable u,
const Variable v 
)
friend

◆ operator==

bool operator== ( const Variable u,
const Variable v 
)
friend

◆ Space

friend class Space
friend

friendship declaration

◆ VariableVector

friend class VariableVector
friend

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