I would like to multiply the inverse of a (potentially large) numpy array by a casadi MX object using the python interface. The goal is to obtain a transformed MX object. Is there some way to do this using numpy/scipy.linalg routines? The following code fails when b is converted to a numpy array by nump.linalg.solve.

import numpy import casadi A = numpy.eye(3) b = casadi.MX('b', 3) x = numpy.linalg.solve(A, b) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python27\lib\site-packages\numpy\linalg\linalg.py", line 307, in solve b, wrap = _makearray(b) File "C:\Python27\lib\site-packages\numpy\linalg\linalg.py", line 67, in _makearray new = asarray(a) File "C:\Python27\lib\site-packages\numpy\core\numeric.py", line 235, in asarray return array(a, dtype, copy=False, order=order) File "C:\Python27\lib\site-packages\casadi\casadi.py", line 10197, in __array__ return self.__array_custom__(*args,**kwargs) File "C:\Python27\lib\site-packages\casadi\casadi.py", line 10203, in __array_custom__ raise Exception("MX cannot be converted to an array. MX.__array__ purely exists to allow ufunc/numpy goodies") Exception: MX cannot be converted to an array. MX.__array__ purely exists to allow ufunc/numpy goodies

I actually need to do this operation many times with the same matrix but different right hands sides, so I would prefer to use scipy.linalg.cho_factor to factorize the matrix and then run scipy.linalg.cho_solve to evaluate the operation.

Thanks!