-  3.39.22
Public Member Functions | List of all members
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
 normalized
 
 pos
 
- 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
ConstraintReal.__init__

Constructor & Destructor Documentation

◆ __init__()

def pyfaust.factparams.ConstraintReal.__init__ (   self,
  name,
  num_rows,
  num_cols,
  cons_value,
  normalized = False,
  pos = False 
)

Constructs a real type constraint.

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

Examples

>>> 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
>>> norm(M[:,2])
18.91380623771181
>>> norm(cons.project(M)[:,2])
1.9999999999999998
See also
ConstraintGeneric.__init__

Reimplemented from pyfaust.factparams.ConstraintGeneric.

Member Function Documentation

◆ project()

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

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:3894
pyfaust.seed
def seed(s)
(Re)Initializes the pyfaust pseudo-random generator.
Definition: __init__.py:5277
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:4966
pyfaust.factparams
The module for the parameterization of FAuST's algorithms (Palm4MSA and Hierarchical Factorization)....
Definition: factparams.py:1