Example #1
0
    def __rmul__(self, other: Union[Number, 'Map']) -> 'MapComp':
        if isinstance(other, Number):
            from pycsou.linop.base import HomothetyMap

            other = HomothetyMap(constant=other, size=self.shape[0])

        if isinstance(other, Map):
            return MapComp(other, self)
        else:
            raise NotImplementedError
Example #2
0
    def __mul__(self, other: Union[Number, 'Map', 'DifferentiableMap', np.ndarray]) \
            -> Union['MapComp', 'DiffMapComp', np.ndarray]:
        if isinstance(other, Number):
            from pycsou.linop.base import HomothetyMap

            other = HomothetyMap(constant=other, size=self.shape[1])

        if isinstance(other, np.ndarray):
            return self(other)
        elif isinstance(other, DifferentiableMap):
            return DiffMapComp(self, other)
        elif isinstance(other, Map):
            return MapComp(self, other)
        else:
            raise NotImplementedError
Example #3
0
    def __rmul__(
        self, other: Union['Map', 'DifferentiableMap', 'LinearOperator',
                           Number]
    ) -> Union['MapSum', 'DiffMapSum', 'LinOpSum']:
        if isinstance(other, Number):
            from pycsou.linop.base import HomothetyMap

            other = HomothetyMap(constant=other, size=self.shape[0])

        if isinstance(other, LinearOperator):
            return LinOpComp(other, self)
        elif isinstance(other, DifferentiableMap):
            return DiffMapComp(other, self)
        elif isinstance(other, Map):
            return MapComp(other, self)
        else:
            raise NotImplementedError
Example #4
0
    def __mul__(
        self, other: Union[Number, 'Map',
                           np.ndarray]) -> Union['MapComp', np.ndarray]:
        r"""
        Multiply a map with another map, a scalar, or an array.

        The behaviour of this method depends on the type of ``other``:

        * If ``other`` is another map, then it returns the composition of the map with ``other``.
        * If ``other`` is an array with compatible shape, then it calls the map on ``other``.
        * If ``other`` is a scalar, then it multiplies the map with this scalar.

        Parameters
        ----------
        other: Union[Number, 'Map', np.ndarray]
            Scalar, map or array with which to multiply.

        Returns
        -------
        :py:class:`~pycsou.core.map.MapComp`, np.ndarray
            Composition of the map with another map, or product with a scalar or array.

        Raises
        ------
        NotImplementedError
            If ``other`` is not a scalar, a map or an array.

        See Also
        --------
        :py:func:`~pycsou.core.map.Map.__matmul__`, :py:func:`~pycsou.core.map.Map.__rmul__`

        """
        if isinstance(other, Number):
            from pycsou.linop.base import HomothetyMap

            other = HomothetyMap(constant=other, size=self.shape[1])

        if isinstance(other, np.ndarray):
            return self(other)
        elif isinstance(other, Map):
            return MapComp(self, other)
        else:
            raise NotImplementedError