Skip to content

brahmap.base.ZeroOperator

Bases: LinearOperator

A linear operator for a zero matrix of shape (nargout, nargin)

Parameters:

Name Type Description Default
nargin int

description

required
nargout int

description

required
**kwargs Any

description

{}
Source code in brahmap/base/linop.py
class ZeroOperator(LinearOperator):
    """A linear operator for a zero matrix of shape `(nargout, nargin)`

    Parameters
    ----------
    nargin : int
        _description_
    nargout : int
        _description_
    **kwargs: Any
        _description_
    """

    def __init__(self, nargin: int, nargout: int, **kwargs: Any):
        if "matvec" in kwargs:
            kwargs.pop("matvec")
        if "rmatvec" in kwargs:
            kwargs.pop("rmatvec")

        def matvec(x):
            if x.shape != (nargin,):
                msg = "Input has shape " + str(x.shape)
                msg += " instead of (%d,)" % self.nargin
                raise ValueError(msg)
            return np.zeros(nargout)

        def rmatvec(x):
            if x.shape != (nargout,):
                msg = "Input has shape " + str(x.shape)
                msg += " instead of (%d,)" % self.nargout
                raise ValueError(msg)
            return np.zeros(nargin)

        super(ZeroOperator, self).__init__(
            nargin, nargout, matvec=matvec, rmatvec=rmatvec, **kwargs
        )