/[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 124 by jgs, Wed Jul 20 06:14:58 2005 UTC revision 126 by jgs, Fri Jul 22 03:53:08 2005 UTC
# Line 555  class Ln_Symbol(Symbol): Line 555  class Ln_Symbol(Symbol):
555    
556  def sin(arg):  def sin(arg):
557      """      """
558      @brief applies the sinus function to arg      @brief applies the sin function to arg
559      @param arg (input): argument      @param arg (input): argument
560      """      """
561      if isinstance(arg,Symbol):      if isinstance(arg,Symbol):
# Line 566  def sin(arg): Line 566  def sin(arg):
566         return numarray.sin(arg)         return numarray.sin(arg)
567    
568  class Sin_Symbol(Symbol):  class Sin_Symbol(Symbol):
569     """symbol representing logarithm of the argument"""     """symbol representing sin of the argument"""
570     def __init__(self,arg):     def __init__(self,arg):
571         Symbol.__init__(self,shape=arg.getShape(),dim=arg.getDim(),args=[arg])         Symbol.__init__(self,shape=arg.getShape(),dim=arg.getDim(),args=[arg])
572     def __str__(self):     def __str__(self):
# Line 578  class Sin_Symbol(Symbol): Line 578  class Sin_Symbol(Symbol):
578    
579  def cos(arg):  def cos(arg):
580      """      """
581      @brief applies the sinus function to arg      @brief applies the cos function to arg
582      @param arg (input): argument      @param arg (input): argument
583      """      """
584      if isinstance(arg,Symbol):      if isinstance(arg,Symbol):
# Line 589  def cos(arg): Line 589  def cos(arg):
589         return numarray.cos(arg)         return numarray.cos(arg)
590    
591  class Cos_Symbol(Symbol):  class Cos_Symbol(Symbol):
592     """symbol representing logarithm of the argument"""     """symbol representing cos of the argument"""
593     def __init__(self,arg):     def __init__(self,arg):
594         Symbol.__init__(self,shape=arg.getShape(),dim=arg.getDim(),args=[arg])         Symbol.__init__(self,shape=arg.getShape(),dim=arg.getDim(),args=[arg])
595     def __str__(self):     def __str__(self):
# Line 601  class Cos_Symbol(Symbol): Line 601  class Cos_Symbol(Symbol):
601    
602  def tan(arg):  def tan(arg):
603      """      """
604      @brief applies the sinus function to arg      @brief applies the tan function to arg
605      @param arg (input): argument      @param arg (input): argument
606      """      """
607      if isinstance(arg,Symbol):      if isinstance(arg,Symbol):
# Line 612  def tan(arg): Line 612  def tan(arg):
612         return numarray.tan(arg)         return numarray.tan(arg)
613    
614  class Tan_Symbol(Symbol):  class Tan_Symbol(Symbol):
615     """symbol representing logarithm of the argument"""     """symbol representing tan of the argument"""
616     def __init__(self,arg):     def __init__(self,arg):
617         Symbol.__init__(self,shape=arg.getShape(),dim=arg.getDim(),args=[arg])         Symbol.__init__(self,shape=arg.getShape(),dim=arg.getDim(),args=[arg])
618     def __str__(self):     def __str__(self):
# Line 660  def maxval(arg): Line 660  def maxval(arg):
660         return arg         return arg
661    
662  class Max_Symbol(Symbol):  class Max_Symbol(Symbol):
663     """symbol representing the sign of the argument"""     """symbol representing the maximum value of the argument"""
664     def __init__(self,arg):     def __init__(self,arg):
665         Symbol.__init__(self,shape=arg.getShape(),dim=arg.getDim(),args=[arg])         Symbol.__init__(self,shape=arg.getShape(),dim=arg.getDim(),args=[arg])
666     def __str__(self):     def __str__(self):
# Line 670  class Max_Symbol(Symbol): Line 670  class Max_Symbol(Symbol):
670    
671  def minval(arg):  def minval(arg):
672      """      """
673      @brief returns the maximum value of argument arg""      @brief returns the minimum value of argument arg""
674      @param arg (input): argument      @param arg (input): argument
675      """      """
676      if isinstance(arg,Symbol):      if isinstance(arg,Symbol):
# Line 683  def minval(arg): Line 683  def minval(arg):
683         return arg         return arg
684    
685  class Min_Symbol(Symbol):  class Min_Symbol(Symbol):
686     """symbol representing the sign of the argument"""     """symbol representing the minimum value of the argument"""
687     def __init__(self,arg):     def __init__(self,arg):
688         Symbol.__init__(self,shape=arg.getShape(),dim=arg.getDim(),args=[arg])         Symbol.__init__(self,shape=arg.getShape(),dim=arg.getDim(),args=[arg])
689     def __str__(self):     def __str__(self):
# Line 693  class Min_Symbol(Symbol): Line 693  class Min_Symbol(Symbol):
693    
694  def wherePositive(arg):  def wherePositive(arg):
695      """      """
696      @brief returns the maximum value of argument arg""      @brief returns the positive values of argument arg""
697      @param arg (input): argument      @param arg (input): argument
698      """      """
699      if _testForZero(arg):      if _testForZero(arg):
# Line 721  class WherePositive_Symbol(Symbol): Line 721  class WherePositive_Symbol(Symbol):
721    
722  def whereNegative(arg):  def whereNegative(arg):
723      """      """
724      @brief returns the maximum value of argument arg""      @brief returns the negative values of argument arg""
725      @param arg (input): argument      @param arg (input): argument
726      """      """
727      if _testForZero(arg):      if _testForZero(arg):
# Line 768  def outer(arg0,arg1): Line 768  def outer(arg0,arg1):
768            raise ValueError,"outer is not fully implemented yet."            raise ValueError,"outer is not fully implemented yet."
769    
770  class Outer_Symbol(Symbol):  class Outer_Symbol(Symbol):
771     """symbol representing the outer product of its two argument"""     """symbol representing the outer product of its two arguments"""
772     def __init__(self,arg0,arg1):     def __init__(self,arg0,arg1):
773         a=[arg0,arg1]         a=[arg0,arg1]
774         s=tuple(list(_identifyShape(arg0))+list(_identifyShape(arg1)))         s=tuple(list(_identifyShape(arg0))+list(_identifyShape(arg1)))
# Line 935  def trace(arg,axis0=0,axis1=1): Line 935  def trace(arg,axis0=0,axis1=1):
935            for j in range(s[1]):            for j in range(s[1]):
936               out+=arg[i,j]               out+=arg[i,j]
937         return out         return out
938         # end hack for transpose         # end hack for trace
939         return arg.transpose(axis0=axis0,axis1=axis1)         return arg.transpose(axis0=axis0,axis1=axis1)
940      else:      else:
941         return numarray.trace(arg,axis0=axis0,axis1=axis1)         return numarray.trace(arg,axis0=axis0,axis1=axis1)
# Line 980  def length(arg): Line 980  def length(arg):
980                        sum+=arg[i,j,k,l]**2                        sum+=arg[i,j,k,l]**2
981            return sqrt(sum)            return sqrt(sum)
982         else:         else:
983            raise SystemError,"length is not been implemented yet"            raise SystemError,"length is not been fully implemented yet"
984         # return arg.length()            # return arg.length()
985      else:      else:
986         return sqrt((arg**2).sum())         return sqrt((arg**2).sum())
987    
# Line 1050  def matrixmult(arg0,arg1): Line 1050  def matrixmult(arg0,arg1):
1050            out=escript.Data(0,(arg0.getShape()[0],),arg0.getFunctionSpace())            out=escript.Data(0,(arg0.getShape()[0],),arg0.getFunctionSpace())
1051            for i in range(arg0.getShape()[0]):            for i in range(arg0.getShape()[0]):
1052               for j in range(arg0.getShape()[1]):               for j in range(arg0.getShape()[1]):
1053                   # uses Data object slicing, plus Data * and += operators
1054                 out[i]+=arg0[i,j]*arg1[j]                 out[i]+=arg0[i,j]*arg1[j]
1055            return out            return out
1056        else:        else:
# Line 1201  if __name__=="__main__": Line 1202  if __name__=="__main__":
1202    
1203  #  #
1204  # $Log$  # $Log$
1205    # Revision 1.13  2005/07/22 03:53:01  jgs
1206    # Merge of development branch back to main trunk on 2005-07-22
1207    #
1208    # Revision 1.12  2005/07/20 06:14:58  jgs
1209    # added ln(data) style wrapper for data.ln() - also added corresponding
1210    # implementation of Ln_Symbol class (not sure if this is right though)
1211    #
1212    # Revision 1.11  2005/07/08 04:07:35  jgs
1213    # Merge of development branch back to main trunk on 2005-07-08
1214    #
1215    # Revision 1.10  2005/06/09 05:37:59  jgs
1216    # Merge of development branch back to main trunk on 2005-06-09
1217    #
1218    # Revision 1.2.2.19  2005/07/21 04:01:28  jgs
1219    # minor comment fixes
1220    #
1221    # Revision 1.2.2.18  2005/07/21 01:02:43  jgs
1222    # commit ln() updates to development branch version
1223    #
1224  # Revision 1.12  2005/07/20 06:14:58  jgs  # Revision 1.12  2005/07/20 06:14:58  jgs
1225  # added ln(data) style wrapper for data.ln() - also added corresponding  # added ln(data) style wrapper for data.ln() - also added corresponding
1226  # implementation of Ln_Symbol class (not sure if this is right though)  # implementation of Ln_Symbol class (not sure if this is right though)

Legend:
Removed from v.124  
changed lines
  Added in v.126

  ViewVC Help
Powered by ViewVC 1.1.26