-  3.41.0
pyfaust.factparams.ConstraintMat Class Reference

This class represents a matrix-based constraint to apply on a matrix. More...

Public Member Functions

def __init__ (self, name, cons_value=None, shape=None, normalized=None, pos=False, cons_value_sz=None)
 Constructs a matrix type constraint. More...
def project (self, M)
- Public Member Functions inherited from pyfaust.factparams.ConstraintGeneric
def is_int_constraint (self)
 Returns True if this constraint is a ConstraintInt, False otherwise. More...
def is_real_constraint (self)
 Returns True if this constraint is a ConstraintReal, False otherwise. More...
def is_mat_constraint (self)
 Returns True if this constraint is a ConstraintMat, False otherwise. More...
def __repr__ (self)

Public Attributes

- Public Attributes inherited from pyfaust.factparams.ConstraintGeneric

Static Public Attributes

dictionary normalized_default

Additional Inherited Members

- Properties inherited from pyfaust.factparams.ConstraintGeneric
 name = property
 Property to access the ConstraintName of the constraint. More...
 shape = property

Detailed Description

This class represents a matrix-based constraint to apply on a matrix.

See also

Constructor & Destructor Documentation

◆ __init__()

def pyfaust.factparams.ConstraintMat.__init__ (   self,
  cons_value = None,
  shape = None,
  normalized = None,
  pos = False,
  cons_value_sz = None 

Constructs a matrix type constraint.

name(ConstraintName or str) must be a ConstraintName instance set with a value among ID, SUPP, CONST, TOEPLITZ or (AANTI)CIRC(ULANT) (cf. ConstraintName) or it can also be one of the more handy str aliases which are respectively: 'supp' and 'const'.
cons_value(np.ndarray) the value of the constraint, it must be a numpy.array
shape(tuple) the shape of the matrix (only useful for identity prox, ConstraintName.ID. In this case the cons_value argument is None). that defines the constraint (the matrix support for SUPP and the constant matrix for CONST).
normalized(bool or NoneType) None because the default value depends on the constraint name (it can be False or True, see ConstraintMat.normalized_default).


>>> from pyfaust.factparams import ConstraintMat
>>> from numpy.random import rand, seed
>>> from numpy import eye
>>> from numpy.linalg import norm
>>> cons = ConstraintMat('supp', eye(10))
>>> seed(42) # just for reproducibility
>>> M = rand(10,10)
>>> from numpy import count_nonzero
>>> count_nonzero(M)
>>> count_nonzero(cons.project(M))
>>> from numpy import diag
>>> diag(M)
array([0.37454012, 0.96990985, 0.29214465, 0.94888554, 0.25877998,
0.92187424, 0.14092422, 0.07404465, 0.88721274, 0.10789143])
>>> diag(cons.project(M))
array([0.19194101, 0.49705083, 0.14971571, 0.48627647, 0.13261728,
0.47243396, 0.0722196 , 0.03794575, 0.45467094, 0.05529124])
>>> float(norm(cons.project(M)))
See also

Reimplemented from pyfaust.factparams.ConstraintGeneric.

Member Function Documentation

◆ project()

def pyfaust.factparams.ConstraintMat.project (   self,

Member Data Documentation

◆ cons_value


◆ normalized


◆ normalized_default

dictionary pyfaust.factparams.ConstraintMat.normalized_default
Initial value:
= {ConstraintName.ID: False, ConstraintName.TOEPLITZ: True, ConstraintName.CIRC: True,
ConstraintName.HANKEL: True, ConstraintName.SUPP: True, ConstraintName.CONST: False,
ConstraintName.BLKDIAG: True}

The documentation for this class was generated from the following file:
def norm(F, ord='fro', **kwargs)
Returns Faust.norm(F, ord)` ornumpy.linalg.norm(F, ord)`` depending of F type.
Definition: __init__.py:3917
def seed(s)
(Re)Initializes the pyfaust pseudo-random generator.
Definition: __init__.py:5334
def eye(m, n=None, dtype='float64', dev="cpu")
Faust identity.
Definition: __init__.py:4791
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
The module for the parameterization of FAuST's algorithms (Palm4MSA and Hierarchical Factorization)....
Definition: factparams.py:1