FAµST (Flexible Approximate MUltilayer Sparse Transforms)
3.38.14

The pyfaust module for polynomial basis as Faust objects. More...
Classes  
class  FaustPoly 
Subclass of Faust specialized for orthogonal polynomial basis. More...  
Functions  
def  basis (L, K, basis_name, dev='cpu', T0=None, **kwargs) 
Builds the Faust of the polynomial basis defined on the sparse matrix L. More...  
def  poly (coeffs, basis='chebyshev', L=None, X=None, dev='cpu', out=None, **kwargs) 
Computes the linear combination of the polynomials defined by basis. More...  
def  expm_multiply (A, B, t, K=10, tradeoff='time', dev='cpu', **kwargs) 
Computes an approximate of the action of the matrix exponential of A on B using series of Chebyshev polynomials. More...  
The pyfaust module for polynomial basis as Faust objects.
def pyfaust.poly.basis  (  L,  
K,  
basis_name,  
dev = 'cpu' , 

T0 = None , 

**  kwargs  
) 
Builds the Faust of the polynomial basis defined on the sparse matrix L.
L  the sparse scipy square matrix in CSR format (scipy.sparse.csr_matrix). The dtype must be float32, float64 or complex128 (the dtype might have a large impact on performance). 
K  the degree of the last polynomial, i.e. the K+1 first polynomials are built. 
basis_name  'chebyshev', and others yet to come. 
dev  the device to instantiate the returned Faust ('cpu' or 'gpu'). 
T0  a sparse matrix to replace the identity as a 0degree polynomial of the basis. 
Examples
Faust size 200x50, density 0.0699, nnz_sum 699, 4 factor(s):
Generate the next basis (the one with one additional dimension, whose the polynomial greatest degree is K+1 = 4)
Faust size 250x50, density 0.08256, nnz_sum 1032, 5 factor(s):
The factors 0 to 3 of G are views of the same factors of F.
By default, the 0degree polynomial is the identity. However it is possible to replace the corresponding matrix by any csr sparse matrix T0 of your choice (with the only constraint that T0.shape[0] == L.shape[0]. In that purpose, do as follows:
Faust size 200x2, density 1.7475, nnz_sum 699, 4 factor(s):
def pyfaust.poly.expm_multiply  (  A,  
B,  
t,  
K = 10 , 

tradeoff = 'time' , 

dev = 'cpu' , 

**  kwargs  
) 
Computes an approximate of the action of the matrix exponential of A on B using series of Chebyshev polynomials.
A  the operator whose exponential is of interest (must be a symmetric positive definite csr_matrix). 
B  (ndarray) the matrix or vector to be multiplied by the matrix exponential of A. 
t  (list) the time points. 
dev  (str, optional) the device ('cpu' or 'gpu') on which to compute (currently only cpu is supported). 
K  the greatest polynomial degree of the Chebyshev polynomial basis. The greater it is, the better is the approximate accuracy but note that a larger K increases the computational cost. 
tradeoff  'memory' or 'time' to specify what matters the most: a small memory footprint or a small time of execution. It changes the implementation of pyfaust.poly.poly used behind. It can help when the memory size is limited relatively to the value of K or the size of A and B. 
Examples
def pyfaust.poly.poly  (  coeffs,  
basis = 'chebyshev' , 

L = None , 

X = None , 

dev = 'cpu' , 

out = None , 

**  kwargs  
) 
Computes the linear combination of the polynomials defined by basis.
coeffs  the linear combination coefficients (vector as a numpy.ndarray). Must be in the same dtype as L and X if they are set. 
basis  either the name of the polynomial basis to build on L or the basis if already built externally (as a FaustPoly or an equivalent 
np  if X is not None, basis can only be a FaustPoly). 
L  the sparse scipy square matrix in CSR format (scipy.sparse.csr_matrix) on which the polynomial basis is built if basis is not already a Faust or a numpy.ndarray. The dtype must be float32, float64 or complex128 (the dtype might have a large impact on performance). 
It can't be None if basis is not a FaustPoly or a numpy.ndarray.
X  (np.darray) if X is not None, the linear combination of basis@X is computed (note that the memory space is optimized compared to the manual way of doing first B = basis@X and then calling poly on B with X at None). 
dev  the computing device ('cpu' or 'gpu'). 
out  (np.ndarray) if not None the function result is put into this np.ndarray. Note that out.flags['F_CONTINUOUS'] must be True. Note that this can't work if the function returns a Faust. 
Examples
Faust size 50x50, density 0.3596, nnz_sum 899, 5 factor(s):
Which is equivalent to do as below (in two times):
Faust size 50x50, density 0.3596, nnz_sum 899, 5 factor(s):
Above G is a Faust because F is too. Below the full array of the Faust F is passed, so an array is returned into GA.
<class 'numpy.ndarray'>
But of course they are equal: