Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 0086a7c9 authored by hhakim's avatar hhakim
Browse files

Minor changes.

- pyfaust Faust by matrix mul. returns a numpy.matrix instead of just a ndarray
- Document greed_omp_chol().
parent b2387760
Branches
Tags
No related merge requests found
......@@ -10,6 +10,23 @@ from numpy import matrix, zeros, argmax, empty
from pyfaust import Faust
def greed_omp_chol(x, A, m, stopTol=None, verbose=False):
"""
Runs greedy OMP algorithm optimized by Cholesky decomposition.
Params:
A: the dictionary as a numpy matrix or a Faust.
x: the vector to approximate by A*y.
m: the dimension from which A maps (the number of columns of A).
stopTol: stopping criterion based on the number of iterations (by default it's a
quarter of the size of x) and it can't be greater than the size of x. This
criterion doesn't disable the other criterion based on the precision of
the solution (the algorithm will stop anyway if a precision lower or equal to
1^-16 is reached).
verbose: to enable the verbosity (value to True).
Returns:
y: the solution of x = A*y.
"""
#TODO: check x is a numpy.matrix (or a matrix_csr ?)
sp = x.shape
if(sp[1] == 1):
......@@ -20,8 +37,8 @@ def greed_omp_chol(x, A, m, stopTol=None, verbose=False):
else:
raise Exception("x must be a vector")
if(Faust.isFaust(A) or isinstance(A, matrix)):
P = lambda z : matrix(A*z)
Pt = lambda z : matrix(A.H*z)
P = lambda z : A*z
Pt = lambda z : A.H*z
else:
raise Exception("A must be a Faust or a numpy.matrix. Here A is "
"a:"+str(type(A)))
......
......@@ -399,9 +399,9 @@ cdef class FaustCore:
else:
self.core_faust_cplx.multiply(&yview_cplx[0,0],nbrow_y,nbcol_y,&xview_2D_cplx[0,0],nbrow_x,nbcol_x)
return y
return np.matrix(y, copy=False)
# print information about the faust (size, number of factor, type of factor (dense/sparse) ...)
def display(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment