/[escript]/branches/symbolic_from_3470/escript/py_src/symbolic/functions.py
ViewVC logotype

Diff of /branches/symbolic_from_3470/escript/py_src/symbolic/functions.py

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

revision 3492 by caltinay, Mon Mar 28 05:18:49 2011 UTC revision 3493 by caltinay, Mon Apr 4 04:37:02 2011 UTC
# Line 23  __url__="https://launchpad.net/escript-f Line 23  __url__="https://launchpad.net/escript-f
23  extra functions that can be used in symbolic expressions  extra functions that can be used in symbolic expressions
24  """  """
25    
26  from sympy.core.function import Function  import sympy
27    from sympy.functions import *
28  from sympy import S  from sympy import S
29    
30  class wherePositive(Function):  class wherePositive(sympy.Function):
31      """Returns:      """Returns:
32           1 where expr > 0           1 where expr > 0
33           0 else           0 else
# Line 52  class wherePositive(Function): Line 53  class wherePositive(Function):
53      def _eval_derivative(self, x):      def _eval_derivative(self, x):
54          return S.Zero          return S.Zero
55    
56  class whereNonPositive(Function):  class whereNonPositive(sympy.Function):
57      """Returns:      """Returns:
58           0 where expr > 0           0 where expr > 0
59           1 else           1 else
# Line 72  class whereNonPositive(Function): Line 73  class whereNonPositive(Function):
73      def _eval_derivative(self, x):      def _eval_derivative(self, x):
74          return S.Zero          return S.Zero
75    
76  class whereNegative(Function):  class whereNegative(sympy.Function):
77      """Returns:      """Returns:
78           1 where expr < 0           1 where expr < 0
79           0 else           0 else
# Line 97  class whereNegative(Function): Line 98  class whereNegative(Function):
98      def _eval_derivative(self, x):      def _eval_derivative(self, x):
99          return S.Zero          return S.Zero
100    
101  class whereNonNegative(Function):  class whereNonNegative(sympy.Function):
102      """Returns:      """Returns:
103           0 where expr < 0           0 where expr < 0
104           1 else           1 else
# Line 117  class whereNonNegative(Function): Line 118  class whereNonNegative(Function):
118      def _eval_derivative(self, x):      def _eval_derivative(self, x):
119          return S.Zero          return S.Zero
120    
121  class whereZero(Function):  class whereZero(sympy.Function):
122      """Returns:      """Returns:
123           1 where expr == 0           1 where expr == 0
124           0 else           0 else
# Line 142  class whereZero(Function): Line 143  class whereZero(Function):
143      def _eval_derivative(self, x):      def _eval_derivative(self, x):
144          return S.Zero          return S.Zero
145    
146  class whereNonZero(Function):  class whereNonZero(sympy.Function):
147      """Returns:      """Returns:
148           0 where expr == 0           0 where expr == 0
149           1 else           1 else
# Line 162  class whereNonZero(Function): Line 163  class whereNonZero(Function):
163      def _eval_derivative(self, x):      def _eval_derivative(self, x):
164          return S.Zero          return S.Zero
165    
166  class log10(Function):  class log10(sympy.Function):
167      """Returns the base-10 logarithm of the argument (same as log(x,10))      """Returns the base-10 logarithm of the argument (same as log(x,10))
168      """      """
169      nargs = 1      nargs = 1
# Line 172  class log10(Function): Line 173  class log10(Function):
173          from sympy.functions.elementary.exponential import log          from sympy.functions.elementary.exponential import log
174          return log(arg,10)          return log(arg,10)
175    
176  class inverse(Function):  class inverse(sympy.Function):
177      """Returns the inverse of the argument      """Returns the inverse of the argument
178      """      """
179      nargs = 1      nargs = 1
# Line 182  class inverse(Function): Line 183  class inverse(Function):
183          if arg.is_Number:          if arg.is_Number:
184              return 1./arg              return 1./arg
185    
186  class minval(Function):  class minval(sympy.Function):
187      """Returns the minimum value over all components of the argument      """Returns the minimum value over all components of the argument
188      """      """
189      nargs = 1      nargs = 1
# Line 192  class minval(Function): Line 193  class minval(Function):
193          if arg.is_Number:          if arg.is_Number:
194              return arg              return arg
195    
196  class maxval(Function):  class maxval(sympy.Function):
197      """Returns the maximum value over all components of the argument      """Returns the maximum value over all components of the argument
198      """      """
199      nargs = 1      nargs = 1
# Line 202  class maxval(Function): Line 203  class maxval(Function):
203          if arg.is_Number:          if arg.is_Number:
204              return arg              return arg
205    
206  class trace(Function):  class maximum(sympy.Function):
207        """Returns the maximum over the arguments
208        """
209        pass
210    
211    class minimum(sympy.Function):
212        """Returns the minimum over the arguments
213        """
214        pass
215    
216    class integrate(sympy.Function):
217        """Returns the integral of the argument
218        """
219        nargs = (1,2)
220    
221    class interpolate(sympy.Function):
222        """Returns the argument interpolated on the function space provided
223        """
224        nargs = 2
225    
226    class L2(sympy.Function):
227        """Returns the L2 norm of the argument
228        """
229        nargs = 1
230    
231    class clip(sympy.Function):
232        """Returns the argument clipped to a minimum and maximum value
233        """
234        nargs = (1,2,3)
235    
236    class trace(sympy.Function):
237      """Returns the trace of the argument with optional axis_offset      """Returns the trace of the argument with optional axis_offset
238      """      """
239      nargs = (1,2)      nargs = (1,2)
240    
241  class transpose(Function):  class transpose(sympy.Function):
242      """Returns the transpose of the argument      """Returns the transpose of the argument
243      """      """
244      nargs = (1,2)      nargs = (1,2)
245    
246  class symmetric(Function):  class symmetric(sympy.Function):
247      """Returns the symmetric part of the argument      """Returns the symmetric part of the argument
248      """      """
249      nargs = 1      nargs = 1
# Line 225  class symmetric(Function): Line 256  class symmetric(Function):
256          elif arg.is_Number:          elif arg.is_Number:
257              return arg              return arg
258    
259  class nonsymmetric(Function):  class nonsymmetric(sympy.Function):
260      """Returns the non-symmetric part of the argument      """Returns the non-symmetric part of the argument
261      """      """
262      nargs = 1      nargs = 1
# Line 238  class nonsymmetric(Function): Line 269  class nonsymmetric(Function):
269          elif arg.is_Number:          elif arg.is_Number:
270              return arg              return arg
271    
272  class swap_axes(Function):  class swap_axes(sympy.Function):
273      """Returns the 'swap' of the argument      """Returns the 'swap' of the argument
274      """      """
275      nargs = (1,2,3)      nargs = (1,2,3)
276    
277  class grad(Function):  class grad(sympy.Function):
278      """Returns the spatial gradient of the argument      """Returns the spatial gradient of the argument
279      """      """
280      nargs = (1,2)      nargs = (1,2)
281    
282    class inner(sympy.Function):
283        """Returns the inner product of the arguments
284        """
285        nargs = 2
286    
287    class outer(sympy.Function):
288        """Returns the outer product of the arguments
289        """
290        nargs = 2
291    
292  #  #
293  # vim: expandtab shiftwidth=4:  # vim: expandtab shiftwidth=4:

Legend:
Removed from v.3492  
changed lines
  Added in v.3493

  ViewVC Help
Powered by ViewVC 1.1.26