-  3.41.0
pyfaust.factparams.ConstraintInt Class Reference

This class represents an integer constraint on a matrix. More...

Public Member Functions

def __init__ (self, name, num_rows, num_cols, cons_value, normalized=True, pos=False)
 
def project (self, M)
 See: ConstraintGeneric.project More...
 
- 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 an integer constraint on a matrix.

It constrains a matrix by its column/row-vectors sparsity or also called ConstraintName.SPLIN, ConstraintName.SPCOL, ConstraintName.SPLINCOL.

The other constraint names of this type are: ConstraintName.SP, ConstraintName.SP_POS, which both designate the 0-norm based constraint of the matrix with besides for SP_POS the zero replacement of all negative values.

See also
ConstraintInt.__init__

Constructor & Destructor Documentation

◆ __init__()

def pyfaust.factparams.ConstraintInt.__init__ (   self,
  name,
  num_rows,
  num_cols,
  cons_value,
  normalized = True,
  pos = False 
)
Parameters
name(ConstraintName or str) it must be a ConstraintName instance set with a value among
SP_POS, SP, SPLIN, SPCOL, SPLINCOL, SPTRIU, SPTRIL, SPSYMM (cf. ConstraintName)
or it can also be one of the more handy str aliases which are respectively 'sppos', 'sp', 'splin', 'spcol', 'splincol', 'sptriu', 'sptril', 'spsymm'.
num_rows(int) the number of rows of the constrained matrix.
num_cols(int) the number of columns of the constrained matrix.
cons_value(int) the integer value of the constraint (the 0-norm as sparsity).

Examples

>>> from pyfaust.factparams import ConstraintInt
>>> from numpy.random import rand
>>> import numpy as np
>>> cons = ConstraintInt('sppos', 10, 10, 2) # a short for ConstraintInt(ConstraintName(ConstraintName.SP_POS), 10, 10, 2)
>>> # cons_value == 2 here and this is the 0-norm we want to constrain M to
>>> M = rand(10,10)
>>> np.count_nonzero(M)
100
>>> np.count_nonzero(cons.project(M))
2
See also
ConstraintGeneric.__init__

Reimplemented from pyfaust.factparams.ConstraintGeneric.

Member Function Documentation

◆ project()

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

The documentation for this class was generated from the following file:
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.factparams
The module for the parameterization of FAuST's algorithms (Palm4MSA and Hierarchical Factorization)....
Definition: factparams.py:1