-  3.39.21
Public Member Functions | Public Attributes | List of all members
pyfaust.proj.blockdiag Class Reference

Functor for the BLOCKDIAG projector. More...

Public Member Functions

def __init__ (self, shape, block_shapes, normalized=True, pos=False)
 Constructor. More...
 
def __call__ (self, M)
 Implements the functor. More...
 
- Public Member Functions inherited from pyfaust.proj.proj_gen
def __init__ (self, shape)
 

Public Attributes

 normalized
 
 pos
 
 constraint
 
- Public Attributes inherited from pyfaust.proj.proj_gen
 shape
 

Detailed Description

Functor for the BLOCKDIAG projector.

It sets all values to zero except for the diagonal blocks of the support defined by block_shapes. The i-th diagonal block starts at the row and column indices (block_shapes[i-1][0], block_shapes[i-1][1]) or (0,0) if i == 0 and ends at the row and columns indices (block_shapes[i][0]-1, block_shapes[i][1]-1) or (shape[0], shape[1]) if i == len(block_shapes)-1.

Examples

>>> from pyfaust.proj import blockdiag
>>> import numpy as np
>>> M = np.ones((12,12))
>>> p = blockdiag(M.shape, [(1, 1), (4, 4), (7, 7)], normalized=False)
>>> M_ = p(M)
>>> M_
array([[1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
[0., 1., 1., 1., 1., 0., 0., 0., 0., 0., 0., 0.],
[0., 1., 1., 1., 1., 0., 0., 0., 0., 0., 0., 0.],
[0., 1., 1., 1., 1., 0., 0., 0., 0., 0., 0., 0.],
[0., 1., 1., 1., 1., 0., 0., 0., 0., 0., 0., 0.],
[0., 0., 0., 0., 0., 1., 1., 1., 1., 1., 1., 1.],
[0., 0., 0., 0., 0., 1., 1., 1., 1., 1., 1., 1.],
[0., 0., 0., 0., 0., 1., 1., 1., 1., 1., 1., 1.],
[0., 0., 0., 0., 0., 1., 1., 1., 1., 1., 1., 1.],
[0., 0., 0., 0., 0., 1., 1., 1., 1., 1., 1., 1.],
[0., 0., 0., 0., 0., 1., 1., 1., 1., 1., 1., 1.],
[0., 0., 0., 0., 0., 1., 1., 1., 1., 1., 1., 1.]])

Constructor & Destructor Documentation

◆ __init__()

def pyfaust.proj.blockdiag.__init__ (   self,
  shape,
  block_shapes,
  normalized = True,
  pos = False 
)

Constructor.

Parameters
shape(tuple(int,int)) the size of the input matrix.
block_shapes(list[tuple]) the list of tuples defining the lower right corner of successive diagonal blocks (see class description and example).
normalized(bool) True to normalize the projection image matrix.
pos(bool) True to ignore negative values (replaced by 0).

Member Function Documentation

◆ __call__()

def pyfaust.proj.blockdiag.__call__ (   self,
  M 
)

Implements the functor.

Reimplemented from pyfaust.proj.proj_gen.

Member Data Documentation

◆ constraint

pyfaust.proj.blockdiag.constraint

◆ normalized

pyfaust.proj.blockdiag.normalized

◆ pos

pyfaust.proj.blockdiag.pos

The documentation for this class was generated from the following file:
pyfaust.proj
This module provides matrix projectors.
Definition: proj.py:1