# linear matrix equation

I want to solve the following equation for a matrix solution X:

```
'A*X*B == C'
# in general, they are rectangular with dimensions:
# A m-by-n, B p-by-q, and hence, X n-by-p, C m-by-q
# for simplicity, assume: they are all n-by-n square matrices
```

Are there any tools in SAGE (or Numpy/Scipy, Fortran, ...) for solving equations of this type?

Thanks in advance!

Are A, B and C square matrices?

It can be solved by applying tensor product of A and B, and vectorization of X and C, but it is only a direct method, inefficient. I guess there would already be a good numerical toolbox for this problem? Let's assume all matrices square, have you ever come across with a similar problem?