/[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 2258 by gross, Mon Feb 9 06:10:13 2009 UTC revision 2259 by jfenwick, Tue Feb 10 01:49:44 2009 UTC
# Line 4653  def maximum(*args): Line 4653  def maximum(*args):
4653            out=a*1.            out=a*1.
4654         else:         else:
4655            if isinstance(out,escript.Data) and isinstance(a,escript.Data):            if isinstance(out,escript.Data) and isinstance(a,escript.Data):
4656               out.copyWithMask(a,wherePositive(a-out))           if out.getRank()==0 and a.getRank()>0:
4657            #We need to consider the case where we have scalars and higher
4658            #ranked objects mixed. If the scalar was first it will get
4659            #picked as the initial out and we have a problem,
4660            #so we swap the objects
4661            res=a.copy()    #Deep copy of a
4662            res.copyWithMask(out,wherePositive(out-a))
4663            out=res
4664             else:
4665                    out.copyWithMask(a,wherePositive(a-out))
4666            else:            else:
4667               diff=add(a,-out)               diff=add(a,-out)
4668               out=add(out,mult(wherePositive(diff),diff))               out=add(out,mult(wherePositive(diff),diff))
# Line 4677  def minimum(*args): Line 4686  def minimum(*args):
4686            out=a*1.            out=a*1.
4687         else:         else:
4688            if isinstance(out,escript.Data) and isinstance(a,escript.Data):            if isinstance(out,escript.Data) and isinstance(a,escript.Data):
4689               out.copyWithMask(a,whereNegative(a-out))           if out.getRank()==0 and a.getRank()>0:
4690            #We need to consider the case where we have scalars and higher
4691            #ranked objects mixed. If the scalar was first it will get
4692            #picked as the initial out and we have a problem,
4693            #so we swap the objects
4694            res=a.copy()    #Deep copy of a
4695            res.copyWithMask(out,whereNegative(out-a))
4696            out=res
4697             else:
4698            out.copyWithMask(a,whereNegative(a-out))
4699            else:            else:
4700               diff=add(a,-out)               diff=add(a,-out)
4701               out=add(out,mult(whereNegative(diff),diff))               out=add(out,mult(whereNegative(diff),diff))

Legend:
Removed from v.2258  
changed lines
  Added in v.2259

  ViewVC Help
Powered by ViewVC 1.1.26