What algorithm does Sage use for the product of two matrices?

asked 2022-05-17 20:14:12 +0100

Pawly gravatar image

(am new to Sage and programming in general as you can see. Feel free to expand your answer)

I want to find out how a matrix product is calculated.

M = random_matrix(ZZ, 10, density=1)
N = random_matrix(ZZ, 10, density=1)
M*N

Is it simply identical to M.__mul__(N) in each case? Or does Sage switch to another algorithm if useful - M._multiply_strassen(N) for example?

edit retag flag offensive close merge delete

Comments

The star operation in M*M points to M.__mul__ - this is the called method, the algorithm which is finally taken depends on the class of M and the specific implementation. A closer look at M.__mul__?? shows which logic, and following the logic and the further calls which algorithms are implemented. Possibly M.__rmul__ is also of interest in similar classes.

dan_fulea gravatar imagedan_fulea ( 2022-05-17 23:09:35 +0100 )edit