Package linear_operators :: Module operators :: Class MaskOperator
[hide private]
[frames] | no frames]

Class MaskOperator

source code

              object --+            
                       |            
interface.LinearOperator --+        
                           |        
           SymmetricOperator --+    
                               |    
                DiagonalOperator --+
                                   |
                                  MaskOperator

A subclass of DiagonalOperator with a boolean diagonal. Elements corresponding to zeros of the diagonal are masked out in the output vector.

Attributes ----------- mask : ndarray of type bool and ndim==1

Instance Methods [hide private]
 
__init__(self, mask, **kwargs)
Parameters ---------- mask : ndarray of ones and zeros.
source code

Inherited from DiagonalOperator: __repr__

Inherited from interface.LinearOperator: __add__, __iadd__, __imul__, __isub__, __mul__, __neg__, __pow__, __radd__, __rmul__, __rsub__, __sub__, matmat, matvec, todense

Inherited from interface.LinearOperator (private): _matmat

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from interface.LinearOperator: T

Inherited from object: __class__

Method Details [hide private]

__init__(self, mask, **kwargs)
(Constructor)

source code 

Parameters
----------
mask : ndarray of ones and zeros.
    If mask[i] = 0, the corresponding value will be masked.
    If mask is not a boolean array, it is converted to boolean.

Returns
-------
A MaskOperator instance.

Exemple
-------
>>> import numpy as np
>>> import linear_operators as lo
>>> M = lo.MaskOperator(np.arange(4) % 2)
>>> M.todense()
array([[ 0.,  0.,  0.,  0.],
       [ 0.,  1.,  0.,  0.],
       [ 0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  1.]])

Overrides: object.__init__