[Numpy-discussion] [RFC] should we argue for a matrix power operator, @@?

Fabrice Silva silva at lma.cnrs-mrs.fr
Sun Mar 16 10:49:13 EDT 2014


Le samedi 15 mars 2014 à 04:32 +0000, Nathaniel Smith a écrit :
> Hi all,
> 
> Here's the second thread for discussion about Guido's concerns about
> PEP 465. The issue here is that PEP 465 as currently written proposes
> two new operators, @ for matrix multiplication and @@ for matrix power
> (analogous to * and **):
>   http://legacy.python.org/dev/peps/pep-0465/

Another usecase may rely on tensor contraction.
Matrix multiplication appears to be a particular case of tensor
contraction for matrix seen as 2nd-order tensor : 
(A @ B)_{ij} = A_{ik} B_{kj}
using Einstein summation notation.

@@ might also be used for double contraction as frequently used in
continuum mechanics. For example, the relation between strain and stress
(2nd order tensors) involves the elasticity tensor (a 4nd order one)
using the double contraction :
S_{ij} = C_{ijkl}E_{kl}
that might be simply calculated with S = C @@ E, the variables S, E, C
being instances of whatever class representing tensors.

My two cents




More information about the NumPy-Discussion mailing list