Operator overload * Hadamard-Schur (Element-wise) or Dot Product

Hi, I was wondering if the operator * has been overridden for transformation matrices in COMPAS. I came across this example in transformations where the three transformation matrices Rx, Ry, and Rz seem to have been multiplied together to make a compound transformation. As in Numpy * would perform the Hadamard-Schur (element-wise) product, I am wondering if the operator * has been overridden to act as matrix product in compas?

hi pirouz,

yes indeed * has been implemented as a matrix product for the transformation matrices.

perhaps @ would probably have been more appropriate. that said though, also in numpy * is used for matrix products when dealing with actual matrices (numpy.matrix — NumPy v1.21 Manual) instead of arrays, which i believe was done this way because of similarity with Matlab syntax.

1 Like

Hi Tom, thanks for the superb answer; yet another wonder about numpy :smiley_cat:

iirc, @ is not compatible with py2.7, so it breaks the parser in rhino. not sure if this was the reason, but it is at least another reason in favor of the *.