~fenics-core/ufl/main

« back to all changes in this revision

Viewing changes to ufl/operators.py

  • Committer: Martin Sandve Alnaes
  • Date: 2013-03-15 09:05:43 UTC
  • Revision ID: martinal@simula.no-20130315090543-i5pems1qn3cwbuwi
Add Max(a,b), Min(a,b) using conditionals. Update changelog.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
# Modified by Kristian B. Oelgaard, 2011
24
24
#
25
25
# First added:  2008-04-09
26
 
# Last changed: 2013-03-04
 
26
# Last changed: 2013-03-15
27
27
 
28
28
import operator
29
29
from ufl.log import error, warning
454
454
    # TODO: Add a Sign type for this?
455
455
    return conditional(eq(x, 0), 0, conditional(lt(x, 0), -1, +1))
456
456
 
 
457
def Max(x, y):
 
458
    "UFL operator: Take the maximum of x and y."
 
459
    # TODO: Add a Maximum type for this?
 
460
    return conditional(gt(x, y), x, y)
 
461
 
 
462
def Min(x, y):
 
463
    "UFL operator: Take the minimum of x and y."
 
464
    # TODO: Add a Minimum type for this?
 
465
    return conditional(lt(x, y), x, y)
 
466
 
457
467
#--- Math functions ---
458
468
 
459
469
def _mathfunction(f, cls):