-  3.39.25
pyfaust.proj.splincol Class Reference

Functor for the SPLINCOL projector. More...

Public Member Functions

def __init__ (self, shape, k, normalized=True, pos=False)
 
- Public Member Functions inherited from pyfaust.proj.proj_gen
def __init__ (self, shape)
 
def __call__ (self, M)
 

Public Attributes

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

Detailed Description

Functor for the SPLINCOL projector.

It's the union of SPLIN and SPCOL projectors.

Examples

>>> from pyfaust.proj import splincol, splin, spcol
>>> from numpy.random import rand, seed
>>> import numpy as np
>>> seed(42) # just for reproducibility
>>> M = np.round(rand(5,5), decimals=2)
>>> M
array([[0.37, 0.95, 0.73, 0.6 , 0.16],
[0.16, 0.06, 0.87, 0.6 , 0.71],
[0.02, 0.97, 0.83, 0.21, 0.18],
[0.18, 0.3 , 0.52, 0.43, 0.29],
[0.61, 0.14, 0.29, 0.37, 0.46]])
>>> p1 = splin(M.shape, 3, normalized=False)
>>> p2 = spcol(M.shape, 3, normalized=False)
>>> p = splincol(M.shape, 3, normalized=False)
>>> p1(M)
array([[0. , 0.95, 0.73, 0.6 , 0. ],
[0. , 0. , 0.87, 0.6 , 0.71],
[0. , 0.97, 0.83, 0.21, 0. ],
[0. , 0.3 , 0.52, 0.43, 0. ],
[0.61, 0. , 0. , 0.37, 0.46]])
>>> p2(M)
array([[0.37, 0.95, 0.73, 0.6 , 0. ],
[0. , 0. , 0.87, 0.6 , 0.71],
[0. , 0.97, 0.83, 0. , 0. ],
[0.18, 0.3 , 0. , 0.43, 0.29],
[0.61, 0. , 0. , 0. , 0.46]])
>>> p(M)
array([[0.37, 0.95, 0.73, 0.6 , 0. ],
[0. , 0. , 0.87, 0.6 , 0.71],
[0. , 0.97, 0.83, 0.21, 0. ],
[0.18, 0.3 , 0.52, 0.43, 0.29],
[0.61, 0. , 0. , 0.37, 0.46]])
>>> p1M = p1(M)
>>> p2M = p2(M)
>>> p1M[p1M == p2M] = 0
>>> p1M+p2M
array([[0.37, 0.95, 0.73, 0.6 , 0. ],
[0. , 0. , 0.87, 0.6 , 0.71],
[0. , 0.97, 0.83, 0.21, 0. ],
[0.18, 0.3 , 0.52, 0.43, 0.29],
[0.61, 0. , 0. , 0.37, 0.46]])
>>> (p1M+p2M == p(M)).all()
True

Constructor & Destructor Documentation

◆ __init__()

def pyfaust.proj.splincol.__init__ (   self,
  shape,
  k,
  normalized = True,
  pos = False 
)
Parameters
shape(tuple(int,int)) shape of the input array.
k(int) the integer sparsity (number of nonzeros) targeted per-row and per-column.
normalized(bool) True to normalize the projection image according to its Frobenius norm.
pos(bool) True to skip negative values (replaced by zero) of the matrix to project.

Member Data Documentation

◆ constraint

pyfaust.proj.splincol.constraint

The documentation for this class was generated from the following file:
pyfaust.seed
def seed(s)
(Re)Initializes the pyfaust pseudo-random generator.
Definition: __init__.py:5334
pyfaust.rand
def rand(num_rows, num_cols, num_factors=None, dim_sizes=None, density=None, fac_type='sparse', per_row=True, dev='cpu', dtype='float64', field=None, seed=0)
Generates a random Faust.
Definition: __init__.py:5016
pyfaust.proj
This module provides matrix projectors.
Definition: proj.py:1