/[escript]/trunk/escript/py_src/util.py
ViewVC logotype

Diff of /trunk/escript/py_src/util.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3357 by caltinay, Thu Nov 11 23:26:52 2010 UTC revision 3358 by gross, Wed Nov 17 08:02:32 2010 UTC
# Line 1561  def whereNonPositive(arg): Line 1561  def whereNonPositive(arg):
1561     else:     else:
1562        raise TypeError,"whereNonPositive: Unknown argument type."        raise TypeError,"whereNonPositive: Unknown argument type."
1563    
1564  def whereZero(arg,tol=None,adaptTol=True,rtol=math.sqrt(EPSILON)):  def whereZero(arg,tol=None,rtol=math.sqrt(EPSILON)):
1565     """     """
1566     Returns mask of zero entries of argument ``arg``.     Returns mask of zero entries of argument ``arg``.
1567    
# Line 6215  def negative(arg): Line 6215  def negative(arg):
6215     """     """
6216     return (arg-abs(arg))/2.     return (arg-abs(arg))/2.
6217    
6218  def safeDiv(arg0, arg1):  def safeDiv(arg0, arg1, rtol=None):
6219      """      """
6220      returns arg0/arg1 but return 0 where arg1 is zero      returns arg0/arg1 but return 0 where arg1 is (almost) zero
6221      """      """
6222      m1=whereZero(arg1)      if rtol==None:
6223          m1=whereZero(arg1,tol=0)
6224        else:
6225          m1=whereZero(arg1,tol=None, rtol=rtol)
6226      return arg0/(arg1+m1)*(1-m1)      return arg0/(arg1+m1)*(1-m1)
6227    
6228  def condEval(f, tval, fval):  def condEval(f, tval, fval):

Legend:
Removed from v.3357  
changed lines
  Added in v.3358

  ViewVC Help
Powered by ViewVC 1.1.26