Package esys :: Package escript :: Module util :: Class Symbol
[show private | hide private]
[frames | no frames]

Type Symbol

object --+
         |
        Symbol

Known Subclasses:
DependendSymbol

Symbol class.

Symbol class objects provide the same functionality as numarray.NumArray and escript.Data objects but they do not have a value and therefore cannot be plotted or visualize. The main purpose is the possibilty calculate derivatives with respect to other Symbols used to define a Symbol.
Method Summary
  __init__(self, shape, args, dim)
Creates an instance of a symbol of a given shape.
  __abs__(self)
returns a S{Symbol} representing the absolute value of the object.
  __add__(self, other)
add another object to this object @param other: object to be added to this object @type other: L{escript.Symbol}, C{float}, L{escript.Data}, L{numarray.NumArray}.
  __div__(self, other)
divides this object by other object @param other: object dividing this object @type other: L{escript.Symbol}, C{float}, L{escript.Data}, L{numarray.NumArray}.
  __getitem__(self, index)
returns the slice defined by index...
  __mul__(self, other)
multiplies this object with other object @param other: object to be mutiplied by this object @type other: L{escript.Symbol}, C{float}, L{escript.Data}, L{numarray.NumArray}.
  __neg__(self)
returns -self.
  __pos__(self)
returns +self.
  __pow__(self, other)
raises this object to the power of other @param other: exponent @type other: L{escript.Symbol}, C{float}, L{escript.Data}, L{numarray.NumArray}.
  __radd__(self, other)
add this object to another object @param other: object this object is added to @type other: L{escript.Symbol}, C{float}, L{escript.Data}, L{numarray.NumArray}.
  __rdiv__(self, other)
divides this object by other object @param other: object dividing this object @type other: L{escript.Symbol}, C{float}, L{escript.Data}, L{numarray.NumArray}.
  __rmul__(self, other)
multiplies this object with other object @param other: object this object is multiplied with @type other: L{escript.Symbol}, C{float}, L{escript.Data}, L{numarray.NumArray}.
  __rpow__(self, other)
raises an object to the power of this object @param other: basis @type other: L{escript.Symbol}, C{float}, L{escript.Data}, L{numarray.NumArray}.
  __rsub__(self, other)
subtracts this object from another object @param other: object this object is been subtracted from @type other: L{escript.Symbol}, C{float}, L{escript.Data}, L{numarray.NumArray}.
str __str__(self)
a string representation of the symbol.
  __sub__(self, other)
subtracts another object from this object @param other: object to be subtracted from this object @type other: L{escript.Symbol}, C{float}, L{escript.Data}, L{numarray.NumArray}.
typically escript.Symbol but other types such as float, escript.Data, numarray.NumArray are possible. diff(self, arg)
returns the derivative of the symbol with respect to Symbol arg
a single object or a list of objects getArgument(self, i)
returns the i-th argument of the symbol
list of objects getDifferentiatedArguments(self, arg)
applifies differentials to the arguments of this object and returns the result as a list.
int if the dimension is defined. Otherwise None is returned. getDim(self)
the spatial dimension
str getMyCode(self, argstrs, format)
returns a program code that can be used to evaluate the symbol.
int getRank(self)
the rank of the symbol
tuple of int getShape(self)
the shape of the symbol.
list of objects getSubstitutedArguments(self, argvals)
substitutes symbols in the arguments of this object and returns the result as a list.
bool isAppropriateValue(self, arg)
checks if the given argument arg can be used as a substitution of this object.
escript.Symbol, float, escript.Data, numarray.NumArray depending on the degree of substitution substitute(self, argvals)
assigns new values to symbols in the definition of the symbol.
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __repr__(x)
x.__repr__() <==> repr(x)
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value

Method Details

__init__(self, shape=(), args=[], dim=None)
(Constructor)

Creates an instance of a symbol of a given shape. The symbol may depending on a list of arguments args which may be symbols or any other object.
Parameters:
shape - the shape
           (type=tuple of int)
dim - spatial dimension of the symbol. If dim=None the spatial dimension is undefined.
           (type=None or int)
Overrides:
__builtin__.object.__init__

__abs__(self)

returns a S{Symbol} representing the absolute value of the object.

__add__(self, other)
(Addition operator)

add another object to this object

@param other: object to be added to this object
@type other: L{escript.Symbol}, C{float}, L{escript.Data}, L{numarray.NumArray}.
@return:  a S{Symbol} representing the sum of this object and C{other}
@rtype: L{DependendSymbol}

__div__(self, other)

divides this object by other object

@param other: object dividing this object
@type other: L{escript.Symbol}, C{float}, L{escript.Data}, L{numarray.NumArray}.
@return: a S{Symbol} representing the quotient of this object and C{other}
@rtype: L{DependendSymbol}

__getitem__(self, index)
(Indexing operator)

returns the slice defined by index

@param index: defines a 
@type index: C{slice} or C{int} or a C{tuple} of them
@return: a S{Symbol} representing the slice defined by index
@rtype: L{DependendSymbol}

__mul__(self, other)

multiplies this object with other object

@param other: object to be mutiplied by this object
@type other: L{escript.Symbol}, C{float}, L{escript.Data}, L{numarray.NumArray}.
@return: a S{Symbol} representing the product of the object and C{other}.
@rtype: L{DependendSymbol} or 0 if other is identical to zero.

__neg__(self)

returns -self.

@return:  a S{Symbol} representing the negative of the object
@rtype: L{DependendSymbol}

__pos__(self)

returns +self.

@return:  a S{Symbol} representing the positive of the object
@rtype: L{DependendSymbol}

__pow__(self, other)

raises this object to the power of other

@param other: exponent
@type other: L{escript.Symbol}, C{float}, L{escript.Data}, L{numarray.NumArray}.
@return: a S{Symbol} representing the power of this object to C{other}
@rtype: L{DependendSymbol} or 1 if C{other} is identical to zero.

__radd__(self, other)
(Right-side addition operator)

add this object to another object

@param other: object this object is added to
@type other: L{escript.Symbol}, C{float}, L{escript.Data}, L{numarray.NumArray}.
@return: a S{Symbol} representing the sum of C{other} and this object object
@rtype: L{DependendSymbol}

__rdiv__(self, other)

divides this object by other object

@param other: object dividing this object
@type other: L{escript.Symbol}, C{float}, L{escript.Data}, L{numarray.NumArray}.
@return: a S{Symbol} representing the quotient of C{other} and this object
@rtype: L{DependendSymbol} or 0 if C{other} is identical to zero.

__rmul__(self, other)

multiplies this object with other object

@param other: object this object is multiplied with
@type other: L{escript.Symbol}, C{float}, L{escript.Data}, L{numarray.NumArray}.
@return: a S{Symbol} representing the product of C{other} and the object.
@rtype: L{DependendSymbol} or 0 if other is identical to zero.

__rpow__(self, other)

raises an object to the power of this object

@param other: basis 
@type other: L{escript.Symbol}, C{float}, L{escript.Data}, L{numarray.NumArray}.
@return: a S{Symbol} representing the power of C{other} to this object
@rtype: L{DependendSymbol} or 0 if C{other} is identical to zero.

__rsub__(self, other)

subtracts this object from another object

@param other: object this object is been subtracted from
@type other: L{escript.Symbol}, C{float}, L{escript.Data}, L{numarray.NumArray}.
@return: a S{Symbol} representing the difference of this object and C{other}.
@rtype: L{DependendSymbol}

__str__(self)
(Informal representation operator)

a string representation of the symbol.
Returns:
a string representation of the object
           (type=str)
Overrides:
__builtin__.object.__str__

__sub__(self, other)
(Subtraction operator)

subtracts another object from this object

@param other: object to be subtracted from this object
@type other: L{escript.Symbol}, C{float}, L{escript.Data}, L{numarray.NumArray}.
@return: a S{Symbol} representing the difference of C{other} and this object 
@rtype: L{DependendSymbol}

diff(self, arg)

returns the derivative of the symbol with respect to Symbol arg
Parameters:
arg - the derivative is calculated with respect to arg
           (type=typically escript.Symbol but can also be float, escript.Data, numarray.NumArray depending the involved functions and data.)
Returns:
derivative with respect to arg
           (type=typically escript.Symbol but other types such as float, escript.Data, numarray.NumArray are possible.)

Note: this method is overwritten by a particular Symbol

getArgument(self, i=None)

returns the i-th argument of the symbol
Parameters:
i - index of the argument requested.
           (type=int or None)
Returns:
the vlaue of the i-th argument or i is not specified the list of all arguments.
           (type=a single object or a list of objects)
Raises:
IndexError - if the requested index does not exist

getDifferentiatedArguments(self, arg)

applifies differentials to the arguments of this object and returns the result as a list.
Parameters:
arg - the derivative is calculated with respect to arg
           (type=typically escript.Symbol but can also be float, escript.Data, numarray.NumArray depending the involved functions and data.)
Returns:
list of object obtained by calculating the derivatives of the argumenst with respct to arg
           (type=list of objects)

getDim(self)

the spatial dimension

@return : the spatial dimension
Returns:
int if the dimension is defined. Otherwise None is returned.

getMyCode(self, argstrs, format='escript')

returns a program code that can be used to evaluate the symbol.
Parameters:
argstrs - gives for each argument a string representing the argument for the evaluation.
           (type=list of str.)
format - specifies the format to be used. At the moment only "escript", "str" and "text" are supported.
           (type=str)
Returns:
a piece of program code which can be used to evaluate the expression assuming the values for the arguments are available.
           (type=str)
Raises:
NotImplementedError - if no implementation for the given format is available

Note: This method has to be overwritten by subclasses.

getRank(self)

the rank of the symbol
Returns:
the rank of the symbol. This is length of the shape
           (type=int)

getShape(self)

the shape of the symbol.

@return : the shape of the symbol.
Returns:
tuple of int

getSubstitutedArguments(self, argvals)

substitutes symbols in the arguments of this object and returns the result as a list.
Parameters:
argvals - Symbols and their substitutes. The Symbol u in the expression defining this object is replaced by argvals[u].
           (type=dict with keywords of type Symbol.)
Returns:
list of the object assigned to the arguments through substitution or for the arguments which are not Symbols the value assigned to the argument at instantiation.
           (type=list of objects)

isAppropriateValue(self, arg)

checks if the given argument arg can be used as a substitution of this object. The method checks the shape of arg and, if the spatial dimension is defined, the spatial dimension of arg.
Parameters:
arg - a given object
           (type=

numarray.NumArray,escript.Data,float, int, Symbol)

Returns:
True if arg is a suitbale object to be used for substitution. Otherwise False is returned.
           (type=bool)

substitute(self, argvals)

assigns new values to symbols in the definition of the symbol. The method replaces the Symbol u by argvals[u] in the expression defining this object.
Parameters:
argvals - new values assigned to symbols
           (type=dict with keywords of type Symbol.)
Returns:
result of the substitution process. Operations are executed as much as possible.
           (type=escript.Symbol, float, escript.Data, numarray.NumArray depending on the degree of substitution)
Raises:
NotImplementedError - if no implementation for the given format is available
TypeError - if a value for a Symbol cannot be substituted.

Note: this method has to be overwritten by a particular Symbol


Generated by Epydoc 2.1 on Thu Apr 27 11:16:24 2006 http://epydoc.sf.net