Constant

class devito.types.Constant(*args, **kwargs)[source]

Bases: devito.types.basic.AbstractCachedSymbol, devito.types.args.ArgProvider

Symbol representing a constant, scalar value in symbolic equations. A Constant carries a scalar value.

Parameters
  • name (str) – Name of the symbol.

  • dtype (data-type, optional) – Any object that can be interpreted as a numpy data type. Defaults to np.float32.

Examples

>>> from devito import Constant
>>> c = Constant(name='c')
>>> c
c
>>> c.data
0.0
>>> c.data = 4
>>> c.data
4.0

Notes

The parameters must always be given as keyword arguments, since SymPy uses *args to (re-)create the dimension arguments of the symbolic object.

property data

The value of the data object, as a scalar (int, float, …).

property is_const

True if the symbol value cannot be modified within an Operator (and thus its value is provided by the user directly from Python-land), False otherwise.