'How to multiply many matrices in one go in python? [duplicate]

Suppose I have four matrices, a, b, c, and d.

In Python (with numpy), I need to do result = np.matmul(np.matmul(np.matmul(a,b),c),d) to multiply them.

In MATLAB/GNU Octave, I can multiply them in a much simpler manner, result = a*b*c*d.

Is there any way to multiply matrices in Python, so that I would not have to repeatedly write np.matmul avoid nested brackets?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source