~fenics-core/ufl/spatder2grad

« back to all changes in this revision

Viewing changes to ufl/mathfunctions.py

  • Committer: Martin Sandve Alnæs
  • Date: 2012-03-23 12:42:35 UTC
  • Revision ID: martinal@simula.no-20120323124235-frfes51yroal0w94
Added __slots__ to some more classes, now the only exceptions are the FormArgument classes which need their __dict__s because of the pydolfin multiple inheritance stuff.

Show diffs side-by-side

added added

removed removed

Lines of Context:
99
99
        return "%s(%r)" % (self._name, self._argument)
100
100
 
101
101
class Sqrt(MathFunction):
 
102
    __slots__ = ()
102
103
    def __new__(cls, argument):
103
104
        if isinstance(argument, (ScalarValue, Zero)):
104
105
            return FloatValue(math.sqrt(float(argument)))
108
109
        MathFunction.__init__(self, "sqrt", argument)
109
110
 
110
111
class Exp(MathFunction):
 
112
    __slots__ = ()
111
113
    def __new__(cls, argument):
112
114
        if isinstance(argument, (ScalarValue, Zero)):
113
115
            return FloatValue(math.exp(float(argument)))
117
119
        MathFunction.__init__(self, "exp", argument)
118
120
 
119
121
class Ln(MathFunction):
 
122
    __slots__ = ()
120
123
    def __new__(cls, argument):
121
124
        if isinstance(argument, (ScalarValue, Zero)):
122
125
            return FloatValue(math.log(float(argument)))
130
133
        return math.log(a)
131
134
 
132
135
class Cos(MathFunction):
 
136
    __slots__ = ()
133
137
    def __new__(cls, argument):
134
138
        if isinstance(argument, (ScalarValue, Zero)):
135
139
            return FloatValue(math.cos(float(argument)))
139
143
        MathFunction.__init__(self, "cos", argument)
140
144
 
141
145
class Sin(MathFunction):
 
146
    __slots__ = ()
142
147
    def __new__(cls, argument):
143
148
        if isinstance(argument, (ScalarValue, Zero)):
144
149
            return FloatValue(math.sin(float(argument)))
148
153
        MathFunction.__init__(self, "sin", argument)
149
154
 
150
155
class Tan(MathFunction):
 
156
    __slots__ = ()
151
157
    def __new__(cls, argument):
152
158
        if isinstance(argument, (ScalarValue, Zero)):
153
159
            return FloatValue(math.tan(float(argument)))
157
163
        MathFunction.__init__(self, "tan", argument)
158
164
 
159
165
class Acos(MathFunction):
 
166
    __slots__ = ()
160
167
    def __new__(cls, argument):
161
168
        if isinstance(argument, (ScalarValue, Zero)):
162
169
            return FloatValue(math.acos(float(argument)))
166
173
        MathFunction.__init__(self, "acos", argument)
167
174
 
168
175
class Asin(MathFunction):
 
176
    __slots__ = ()
169
177
    def __new__(cls, argument):
170
178
        if isinstance(argument, (ScalarValue, Zero)):
171
179
            return FloatValue(math.asin(float(argument)))
175
183
        MathFunction.__init__(self, "asin", argument)
176
184
 
177
185
class Atan(MathFunction):
 
186
    __slots__ = ()
178
187
    def __new__(cls, argument):
179
188
        if isinstance(argument, (ScalarValue, Zero)):
180
189
            return FloatValue(math.atan(float(argument)))
193
202
    return None
194
203
 
195
204
class Erf(MathFunction):
 
205
    __slots__ = ()
196
206
    def __new__(cls, argument):
197
207
        if isinstance(argument, (ScalarValue, Zero)):
198
208
            erf = _find_erf()
258
268
        return "%s(%r, %r)" % (self._classname, self._nu, self._argument)
259
269
 
260
270
class BesselJ(BesselFunction):
 
271
    __slots__ = ()
261
272
    def __init__(self, nu, argument):
262
273
        BesselFunction.__init__(self, "cyl_bessel_j", "BesselJ", nu, argument)
263
274
 
264
275
class BesselY(BesselFunction):
 
276
    __slots__ = ()
265
277
    def __init__(self, nu, argument):
266
278
        BesselFunction.__init__(self, "cyl_bessel_y", "BesselY", nu, argument)
267
279
 
268
280
class BesselI(BesselFunction):
 
281
    __slots__ = ()
269
282
    def __init__(self, nu, argument):
270
283
        BesselFunction.__init__(self, "cyl_bessel_i", "BesselI", nu, argument)
271
284
 
272
285
class BesselK(BesselFunction):
 
286
    __slots__ = ()
273
287
    def __init__(self, nu, argument):
274
288
        BesselFunction.__init__(self, "cyl_bessel_k", "BesselK", nu, argument)
 
289