-  3.41.0
pyfaust.factparams.ConstraintName Class Reference

This class defines the names for the sub-types of constraints into the ConstraintGeneric hierarchy of classes. More...

Public Member Functions

def __init__ (self, name)
 Constructor of the ConstraintName object. More...
 
def is_int_constraint (self)
 A delegate for ConstraintGeneric.is_int_constraint. More...
 
def is_real_constraint (self)
 A delegate for ConstraintGeneric.is_real_constraint. More...
 
def is_mat_constraint (self)
 A delegate for ConstraintGeneric.is_mat_constraint. More...
 
def name_str (self)
 Returns the str constant name of this constraint. More...
 

Static Public Member Functions

def name_int2str (_id)
 Converts a int constraint short name to its str constant name equivalent. More...
 
def str2name_int (_str)
 Converts a str constraint short name to its integer constant name equivalent. More...
 

Public Attributes

 name
 

Static Public Attributes

int SP = 0
 
int SPCOL = 1
 
int SPLIN = 2
 
int NORMCOL = 3
 
int SPLINCOL = 4
 
int CONST = 5
 
int SP_POS = 6
 
int BLKDIAG = 7
 
int SUPP = 8
 
int NORMLIN = 9
 
int TOEPLITZ = 10
 
int CIRC = 11
 
int ANTICIRC = 12
 
int HANKEL = 13
 
int SKPERM = 14
 
int ID = 15
 
int SPTRIU = 16
 
int SPTRIL = 17
 
int SPSYMM = 18
 

Detailed Description

This class defines the names for the sub-types of constraints into the ConstraintGeneric hierarchy of classes.

The table here is a summary of the available constraints.

Examples

>>> # SPLINCOL Comprehensive Example
>>> # This constraint doesn't necessarily
>>> # lead to a image matrix with asked sparsity respected
>>> # both for columns and rows
>>> from numpy.random import rand, seed
>>> from numpy.linalg import norm
>>> from pyfaust.factparams import ConstraintInt
>>> import numpy as np
>>> n = 10; m = 10; v = 2;
>>> seed(42) # just for reproducibility
>>> M = rand(10,10)
>>> Mspcol = ConstraintInt('spcol', n, m, v).project(M)
>>> Msplin = ConstraintInt('splin', n, m, v).project(M)
>>> Mp = ConstraintInt('splincol', n, m, v).project(M)
>>> Mp_ = Mspcol + np.where(Mspcol != 0, 0, Msplin) # the sum of Mspcol and Msplin minus their nonzero intersection matrix
>>> Mp_/= norm(Mp_)
>>> # Mp is approximately equal to Mp_
>>> print(norm(Mp-Mp_,2)/norm(Mp_, 2))
0.0041532733089187064
>>> from numpy import count_nonzero
>>> count_nonzero(Mp[:,1])
2
>>> # sparsity value v is not respected
>>> count_nonzero(Mp_[:,1])
2
>>> count_nonzero(Mp_[1,:])
2
>>> count_nonzero(Mp[1,:])
2
>>> # v is respected for this row

Constructor & Destructor Documentation

◆ __init__()

def pyfaust.factparams.ConstraintName.__init__ (   self,
  name 
)

Constructor of the ConstraintName object.

Parameters
namemust be a valid constraint name (integer among the static constants defined in the class: ConstraintName.SP, ...).

Member Function Documentation

◆ is_int_constraint()

def pyfaust.factparams.ConstraintName.is_int_constraint (   self)

◆ is_mat_constraint()

def pyfaust.factparams.ConstraintName.is_mat_constraint (   self)

◆ is_real_constraint()

def pyfaust.factparams.ConstraintName.is_real_constraint (   self)

◆ name_int2str()

def pyfaust.factparams.ConstraintName.name_int2str (   _id)
static

Converts a int constraint short name to its str constant name equivalent.

For example, name_int2str(ConstraintName.SP) returns 'sp'.

◆ name_str()

def pyfaust.factparams.ConstraintName.name_str (   self)

Returns the str constant name of this constraint.

◆ str2name_int()

def pyfaust.factparams.ConstraintName.str2name_int (   _str)
static

Converts a str constraint short name to its integer constant name equivalent.

For example, str2name_int('sp') returns ConstraintName.SP.

Member Data Documentation

◆ ANTICIRC

pyfaust.factparams.ConstraintName.ANTICIRC = 12
static

Designates a constraint to produce an anti-circulant matrix (cf. pyfaust.proj.anticirc).

◆ BLKDIAG

pyfaust.factparams.ConstraintName.BLKDIAG = 7
static

Designates a constraint to produce a block-diagonal matrix (cf. pyfaust.proj.blockdiag).

◆ CIRC

pyfaust.factparams.ConstraintName.CIRC = 11
static

Designates a constraint to produce a circulant matrix (cf. pyfaust.proj.circ).

◆ CONST

pyfaust.factparams.ConstraintName.CONST = 5
static

Designates a constraint imposing to a matrix to be constant.

◆ HANKEL

pyfaust.factparams.ConstraintName.HANKEL = 13
static

Designates a constraint to produce an anti-circulant matrix (cf. pyfaust.proj.hankel).

◆ ID

pyfaust.factparams.ConstraintName.ID = 15
static

Identity prox/constraint.

◆ name

pyfaust.factparams.ConstraintName.name

The name of the constraint (actually an integer among the valid constants).

◆ NORMCOL

pyfaust.factparams.ConstraintName.NORMCOL = 3
static

Designates a 2-norm constraint on each column of a matrix.

◆ NORMLIN

pyfaust.factparams.ConstraintName.NORMLIN = 9
static

Designates a 2-norm constraint on each row of a matrix.

◆ SKPERM

pyfaust.factparams.ConstraintName.SKPERM = 14
static

SKPERM prox/constraint.

◆ SP

pyfaust.factparams.ConstraintName.SP = 0
static

Designates a constraint on the sparsity/0-norm of a matrix.

◆ SP_POS

pyfaust.factparams.ConstraintName.SP_POS = 6
static

Designates a constraint that imposes a SP constraints and besides set to zero the negative coefficients (it doesn't apply to complex matrices).

◆ SPCOL

pyfaust.factparams.ConstraintName.SPCOL = 1
static

Designates a sparsity/0-norm constraint on the columns of a matrix.

◆ SPLIN

pyfaust.factparams.ConstraintName.SPLIN = 2
static

Designates a sparsity/0-norm constraint on the rows of a matrix.

◆ SPLINCOL

pyfaust.factparams.ConstraintName.SPLINCOL = 4
static

Designates a constraint that imposes both SPLIN and SPCOL constraints (see example above for clarification).

◆ SPSYMM

pyfaust.factparams.ConstraintName.SPSYMM = 18
static

Designates a constraint on the sparsity/0-norm of a symmetric matrix.

◆ SPTRIL

pyfaust.factparams.ConstraintName.SPTRIL = 17
static

Designates a constraint on the sparsity/0-norm of lower triangular part of a matrix.

◆ SPTRIU

pyfaust.factparams.ConstraintName.SPTRIU = 16
static

Designates a constraint on the sparsity/0-norm of upper triangular part of a matrix.

◆ SUPP

pyfaust.factparams.ConstraintName.SUPP = 8
static

Designates a constraint by a support matrix S (element-wisely multiplying the matrix to constrain to obtain a matrix for which the 2-norm equals 1, see: ConstraintMat.project()).

◆ TOEPLITZ

pyfaust.factparams.ConstraintName.TOEPLITZ = 10
static

Designates a constraint to produce a toeplitz matrix (cf. pyfaust.proj.toeplitz).


The documentation for this class was generated from the following file:
pyfaust.norm
def norm(F, ord='fro', **kwargs)
Returns Faust.norm(F, ord)` ornumpy.linalg.norm(F, ord)`` depending of F type.
Definition: __init__.py:3917
pyfaust.seed
def seed(s)
(Re)Initializes the pyfaust pseudo-random generator.
Definition: __init__.py:5334
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