-  3.39.21
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
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

 cons_value
 
 normalized
 
- Public Attributes inherited from pyfaust.factparams.ConstraintGeneric
 normalized
 
 pos
 

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
ConstraintMat.__init__

Constructor & Destructor Documentation

◆ __init__()

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

Constructs a matrix type constraint.

Parameters
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).

Examples

>>> 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)
100
>>> count_nonzero(cons.project(M))
10
>>> 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])
>>> norm(cons.project(M))
1.0
See also
ConstraintGeneric.__init__

Reimplemented from pyfaust.factparams.ConstraintGeneric.

Member Function Documentation

◆ project()

def pyfaust.factparams.ConstraintMat.project (   self,
  M 
)

Member Data Documentation

◆ cons_value

pyfaust.factparams.ConstraintMat.cons_value

◆ normalized

pyfaust.factparams.ConstraintMat.normalized

◆ normalized_default

dictionary pyfaust.factparams.ConstraintMat.normalized_default
static
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:
pyfaust.norm
def norm(F, ord='fro', **kwargs)
Returns Faust.norm(F, ord) or numpy.linalg.norm(F, ord) depending of F type.
Definition: __init__.py:3885
pyfaust.seed
def seed(s)
(Re)Initializes the pyfaust pseudo-random generator.
Definition: __init__.py:5268
pyfaust.eye
def eye(m, n=None, dtype='float64', dev="cpu")
Faust identity.
Definition: __init__.py:4734
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:4957
pyfaust.factparams
The module for the parameterization of FAuST's algorithms (Palm4MSA and Hierarchical Factorization)....
Definition: factparams.py:1