Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Public Member Functions | Private Member Functions | List of all members
CellMLToNektar.pycml.mathml_divide Class Reference
Inheritance diagram for CellMLToNektar.pycml.mathml_divide:
Inheritance graph
[legend]
Collaboration diagram for CellMLToNektar.pycml.mathml_divide:
Collaboration graph
[legend]

Public Member Functions

def evaluate
 
- Public Member Functions inherited from CellMLToNektar.pycml.mathml_operator
def wrong_number_of_operands
 
- Public Member Functions inherited from CellMLToNektar.pycml.mathml
def __init__
 
def __repr__
 
def __deepcopy__
 
def clone_self
 
def get_original_of_clone
 
def get_component
 
def model
 
def eval
 
- Public Member Functions inherited from CellMLToNektar.pycml.element_base
def __init__
 
def __delattr__
 
def __setattr__
 
def rootNode
 
def cmeta_id
 
def xml_remove_child_at
 
def xml_doc
 
def xml_properties
 

Private Member Functions

def _reduce
 

Additional Inherited Members

- Static Public Member Functions inherited from CellMLToNektar.pycml.mathml
def clone
 
- Public Attributes inherited from CellMLToNektar.pycml.element_base
 xml_attributes
 
- Properties inherited from CellMLToNektar.pycml.mathml
 component = property(get_component)
 

Detailed Description

Class representing the MathML <divide> operator.

Definition at line 5600 of file pycml.py.

Member Function Documentation

def CellMLToNektar.pycml.mathml_divide._reduce (   self)
private
Reduce this expression by evaluating its static parts.

If the whole expression is static, proceed as normal for an
<apply>.  If just the denominator is static, transform the
expression into a multiplication.

Definition at line 5612 of file pycml.py.

References CellMLToNektar.pycml.mathml_operator.wrong_number_of_operands().

5613  def _reduce(self):
5614  """Reduce this expression by evaluating its static parts.
5615 
5616  If the whole expression is static, proceed as normal for an
5617  <apply>. If just the denominator is static, transform the
5618  expression into a multiplication.
5619  """
5620  app = self.xml_parent
5621  bt = app._get_binding_time()
5622  if bt == BINDING_TIMES.static:
5623  # Evaluate this expression as normal
5624  app._reduce(check_operator=False)
5625  else:
5626  # Check binding time of the denominator
5627  ops = list(app.operands())
5628  if len(ops) != 2:
5629  self.wrong_number_of_operands(len(ops), [2])
5630  bt = app._get_element_binding_time(ops[1])
5631  if bt == BINDING_TIMES.static:
5632  # Create inverse expression and evaluate it
5633  dummy = self.xml_create_element(u'dummy', NSS[u'm'])
5634  app.replace_child(ops[1], dummy)
5635  new_expr = mathml_apply.create_new(
5636  self, u'divide', [(u'1', u'dimensionless'),
5637  ops[1]])
5638  app.replace_child(dummy, new_expr)
5639  app._reduce_elt(new_expr)
5640  # Change this expression to a <times>
5641  times = self.xml_create_element(u'times', NSS[u'm'])
5642  app.replace_child(self, times)
5643  # And finally reduce it as normal
5644  app._reduce(check_operator=False)
5645  else:
5646  # Evaluate this expression as normal
5647  app._reduce(check_operator=False)
def CellMLToNektar.pycml.mathml_divide.evaluate (   self)
Evaluate by dividing the 2 operands of the enclosing <apply>.

Definition at line 5602 of file pycml.py.

References CellMLToNektar.pycml.mathml.eval(), and CellMLToNektar.pycml.mathml_operator.wrong_number_of_operands().

Referenced by CellMLToNektar.pycml.mathml_constructor._eval_self().

5603  def evaluate(self):
5604  """Evaluate by dividing the 2 operands of the enclosing <apply>."""
5605  app = self.xml_parent
5606  ops = list(app.operands())
5607  if len(ops) != 2:
5608  self.wrong_number_of_operands(len(ops), [2])
5609  numer = self.eval(ops[0])
5610  denom = self.eval(ops[1])
5611  return numer/denom