0
$\begingroup$

Say I want to define some simple linear operator. I can do this by

f[c_?NumericQ x_] := c f[x]
f[x_ + y_] := f[x] + f[y]

Or let's define a bi-linear operator instead

f[c_?NumericQ x_, y_] := c f[x, y]
f[x_, c_?NumericQ y_] := c f[x, y]
f[x_ + y_, z_] := f[x, z] + f[y, z]
f[x_, y_ + z_] := f[x, y] + f[x, z]

My problem is that I need to do this kind of things very often and then the definitions like above are repeated over and over. It would probably not be easy to describe all intended uses briefly here, but I hope that my intentions are clear. Isn't there some standard concise way to define operators with some common properties?

$\endgroup$
3
  • $\begingroup$ Do the answers in Defining an operator with given properties and Problem with defining a simple linear operator help at all? $\endgroup$
    – MarcoB
    Apr 18, 2021 at 19:40
  • $\begingroup$ @MarcoB I would say these answers help to build such operators from a scratch. I'm asking rather if there some higher-level ways to give an operator some standard property like linearity, Something like "Attributes[f]=bilinear wrt to numeric factors". $\endgroup$ Apr 19, 2021 at 4:54
  • 1
    $\begingroup$ As far as I know, there isn't any way to achieve that automatically. The implication in pointing out those answers is that, if such functionality existed, it would have been brought up before. $\endgroup$
    – MarcoB
    Apr 19, 2021 at 12:49

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.