Esempio n. 1
0
        def dot(self, x):
            """Matrix-matrix or matrix-vector multiplication.
            Parameters
            ----------
            x : array_like
                1-d or 2-d array, representing a vector or matrix.
            Returns
            -------
            Ax : array
                1-d or 2-d array (depending on the shape of x) that represents
                the result of applying this linear operator on x.
            """
            if isinstance(x, LinearOperator):
                return _ProductLinearOperator(self, x)
            elif np.isscalar(x):
                return _ScaledLinearOperator(self, x)
            else:
                x = np.asarray(x)

                if x.ndim == 1 or x.ndim == 2 and x.shape[1] == 1:
                    return self.matvec(x)
                elif x.ndim == 2:
                    return self.matmat(x)
                else:
                    raise ValueError('expected 1-d or 2-d array or matrix, got %r'
                                     % x)
Esempio n. 2
0
 def __neg__(self):
     return _ScaledLinearOperator(self, -1)
Esempio n. 3
0
 def __rmul__(self, x):
     if np.isscalar(x):
         return _ScaledLinearOperator(self, x)
     else:
         return NotImplemented