Commit 86940bf1 authored by Neel Shah's avatar Neel Shah
Browse files

implement compatibility with sparse matrices

parent 5a7c3863
Pipeline #107177 canceled with stages
......@@ -126,13 +126,16 @@ class MatrixProductOperator(EndomorphicOperator):
if self._spaces is None:
if not self._flatten:
if times:
res = np.tensordot(m,x.val,axes=len(x.shape))
if type(m) == np.ndarray:
if times:
res = np.tensordot(m,x.val,axes=len(x.shape))
else:
mat_axes = np.flip(self._mat_last_n)
field_axes = self._mat_first_n
res = np.tensordot(m,x.val,axes=(mat_axes,field_axes))
res = res.reshape(np.flip(res.shape))
else:
mat_axes = np.flip(self._mat_last_n)
field_axes = self._mat_first_n
res = np.tensordot(m,x.val,axes=(mat_axes,field_axes))
res = res.reshape(np.flip(res.shape))
res = m.dot(x.val)
else:
res = m.dot(x.val.ravel()).reshape(self._domain.shape)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment