-  3.41.0
pyfaust.factparams.ConstraintReal Class Reference

This class represents a real constraint on a matrix. More...

Public Member Functions

def __init__ (self, name, num_rows, num_cols, cons_value, normalized=False, pos=False)
 Constructs a real 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)

Additional Inherited Members

- Public Attributes inherited from pyfaust.factparams.ConstraintGeneric
- 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 real constraint on a matrix.

It constrains a matrix by a column/row-vector 2-norm (ConstraintName.NORMCOL, ConstraintName.NORMLIN).

See also

Constructor & Destructor Documentation

◆ __init__()

def pyfaust.factparams.ConstraintReal.__init__ (   self,
  normalized = False,
  pos = False 

Constructs a real type constraint.

name(ConstraintName or str) must be a ConstraintName instance set with a value among NORMCOL, NORMLIN (cf. ConstraintName) or it can also be one of the more handy str aliases which are respectively: 'normcol', 'normlin'.
num_rows(int) the number of columns of the constrained matrix.
num_cols(int) the number of columns of the constrained matrix.
cons_value(float) the parameter value of the constraint, it must be a float number that designates the 2-norm imposed to all columns (if name is ConstraintName.NORMCOL) or rows (if name is ConstraintName.NORMLIN).


>>> from pyfaust.factparams import ConstraintReal
>>> from numpy.random import rand, seed
>>> from numpy.linalg import norm
>>> seed(42) # just for reproducibility
>>> cons = ConstraintReal('normcol', 10, 10, 2.) # a short for ConstraintReal(ConstraintName(ConstraintName.NORMCOL), 10, 10, 2.)
>>> M = rand(10,10)*10
>>> float(norm(M[:,2]))
>>> float(norm(cons.project(M)[:,2]))
See also

Reimplemented from pyfaust.factparams.ConstraintGeneric.

Member Function Documentation

◆ project()

def pyfaust.factparams.ConstraintReal.project (   self,

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 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