Conversation
| else: | ||
| return NotImplemented | ||
|
|
||
| def __matmul__(self, other): |
There was a problem hiding this comment.
If this class inherits from ufl.Matrix, and ufl.Matrix is a BaseForm, shouldn't it already inherit addition and scalar multiplication?
I'm not aware of matrix multiplication being implemented in BaseForm, but it seems that it would not harm to have it there.
There was a problem hiding this comment.
Matrix multiplication is there, but it seems that it only supports multiplication times a Function (and breaks for Cofunction and Matrix).
https://github.com/FEniCS/ufl/blob/main/ufl/form.py#L247
https://github.com/FEniCS/ufl/blob/main/ufl/form.py#L219-L225
| def __truediv__(self, other): | ||
| # Scalar division | ||
| if isinstance(other, Complex | Constant): | ||
| other = other.values().item() if isinstance(other, Constant) else other |
There was a problem hiding this comment.
This is a bit dangerous, we are silently freezing the Constant. This returns a symbolic expression that no longer makes reference to the Constant, which is inconsistent with how scalar multiplication is implemented.
There was a problem hiding this comment.
It might be better to leave this one for a separate PR where we enable BaseFormAssembler to numerically evaluate constant-valued symbolic expressions in the weights of a FormSum.
There was a problem hiding this comment.
BTW, FormSum should be able to deal with non-float weights, so I 1/Constant should be fine
No description provided.