
3.39.20

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  (scipy.sparse.csr_matrix) the sparse square matrix. The dtype must be float32, float64 or complex128 (the dtype might have a large impact on performance). 
K  (int) the degree of the last polynomial, i.e. the K+1 first polynomials are built. basis_name: 'chebyshev', and others yet to come. 
dev  (str) the device to instantiate the returned Faust ('cpu' or 'gpu'). 
T0  (Faust or scipy.sparse.csr_matrix) to define the 0degree polynomial as something else than the identity. If a Faust only the first factor is take into account. 
Examples
Faust size 200x50, density 0.0672, nnz_sum 672, 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.07968, nnz_sum 996, 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.68, nnz_sum 672, 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  (scipy.sparse.csr_matrix) the operator whose exponential is of interest (must be a symmetric positive definite matrix). 
B  (np.ndarray) the matrix or vector to be multiplied by the matrix exponential of A. 
t  (list[float]) the time points. 
dev  (str) the device ('cpu' or 'gpu') on which to compute (currently only cpu is supported). 
K  (int) 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  (str) '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  (np.ndarray) the linear combination coefficients (vector). Must be in the same dtype as L and X if they are set. 
basis  (FaustPoly or np.ndarray) 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  (scipy.sparse.csr_matrix) The square 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  (str) 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.3488, nnz_sum 872, 5 factor(s):
Which is equivalent to do as below (in two times):
Faust size 50x50, density 0.3488, nnz_sum 872, 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: