From perspective of calculation time of matrix multiplications Infix operators is a reasonable solution to define a subset of your own. https://doc.sagemath.org/html/en/reference/misc/sage/misc/decorators.html#sage.misc.decorators.infix_operator
The problem is that if one implements it, there has to be a substitution at the expense of loosing a default operator. In scientific libraries this isn't great as all existing operators tend to be used. What I would alternatively propose is to introduce a couple of (meaningless operators), so that library developers can make use of them as they wish. What characters aren't used? “$, ?, `” (or are they?). A $pow$ 3 - meh A ?pow? 3 - looks ok. The question mark is appropriately marking ambiguous/implementation dependent meaning. A `pow` 3 - looks good A @@ 3 - doesn’t look too great... A.pow(3) - nice If I was lacking just one operator (especially in such case where different algorithms can be used), A.pow(-1, inv_type=‘LU') feels most convenient given flexibility of arguments. If I was to go heavy on operators in matrix algebra or defining some sort of new syntax, then @@ wouldn’t help anyways - it’s just one (and fairly awful looking). > On 5 Jul 2023, at 13:02, ha...@interia.pl wrote: > > > Python has the "star" ("*") operator for multiplication. In the context of > collections it is supposed to mean element-wise multiplication. Its > associated operator is __mul__. It also has the double star ("**") operator > for exponentiation, which is repeated multiplication. Its associated operator > is __exp__. > > In addition to that Python has the "at" ("@") operator for multiplication. In > the context of collections it should mean linear product, like matrix times a > matrix, or matrix times vector. Its associated method is __matmul__. > > For completeness we should now have the exponentiation operator meaning > repeated application of the "at" operator. Its method could me __matexp__. > _______________________________________________ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/AS3F4V4PCR4EUMYGC7HEECQHAFUVNU2M/ > Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/F7ZNL3FCVY7HAXGB52D5HOOFG2RQFA7B/ Code of Conduct: http://python.org/psf/codeofconduct/