-  3.39.21
Functions
pyfaust.tools Namespace Reference

The pyfaust tools module. More...

Functions

def omp (y, D, maxiter=None, tol=0, relerr=True, verbose=False)
 Runs the greedy OMP algorithm optimized by Cholesky decomposition. More...
 

Detailed Description

The pyfaust tools module.

Function Documentation

◆ omp()

def pyfaust.tools.omp (   y,
  D,
  maxiter = None,
  tol = 0,
  relerr = True,
  verbose = False 
)

Runs the greedy OMP algorithm optimized by Cholesky decomposition.

Parameters
y(np.ndarray) the vector to approximate by D@x.
D(np.ndarray or a Faust) the dictionary as a numpy array or a Faust.
maxiter(int or NoneType) the maximum number of iterations of the algorithm. By default (None) it's y's dimension: max(y.shape).
tol(float) the tolerance error to reach for the algorithm to stop. By default, it's zero for not stopping on error criterion.
relerr(bool) the type of error stopping criterion. Default to True to use relative error, otherwise (False) the absolute error is used.
verbose(bool) to enable the verbosity (True).
Returns
x the solution of y = D@x (according to the error).

Examples

>>> from pyfaust.tools import omp
>>> from scipy.sparse import random
>>> from pyfaust import rand, seed
>>> import numpy as np
>>> np.random.seed(42) # just for reproducibility
>>> seed(42)
>>> D = rand(1024, 1024)
>>> x0 = random(1024, 1, .01)
>>> y = D @ x0
>>> maxiter = 17
>>> x = omp(y, D, maxiter, tol=10**-16)

Stopping. Exact signal representation found!

>>> # omp() runs at most maxiter iterations until the error tolerance is
>>> # reached
pyfaust.tools
The pyfaust tools module.
Definition: tools.py:1
pyfaust.seed
def seed(s)
(Re)Initializes the pyfaust pseudo-random generator.
Definition: __init__.py:5268
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.tools.omp
def omp(y, D, maxiter=None, tol=0, relerr=True, verbose=False)
Runs the greedy OMP algorithm optimized by Cholesky decomposition.
Definition: tools.py:94