-
3.39.12
|
The matfaust module for polynomial basis as Faust objects. More...
Classes | |
class | FaustPoly |
Subclass of Faust specialized for orthogonal polynomial basis. More... | |
Functions | |
function | basis (L, K, basis_name, varargin) |
Builds the Faust of the polynomial basis defined on the sparse matrix L. More... | |
function | expm_multiply (A, B, t, varargin) |
Computes an approximate of the action of the matrix exponential of A on B using series of Chebyshev polynomials. More... | |
function | next (F) |
Gives the next Faust basis of dimension (n+1) from the Faust F polynomial basis of dimension n. More... | |
function | poly (coeffs, basis, varargin) |
Computes the linear combination of the polynomials defined by basis. More... | |
The matfaust module for polynomial basis as Faust objects.
function matfaust::poly::basis | ( | L | , |
K | , | ||
basis_name | , | ||
varargin | |||
) |
Builds the Faust of the polynomial basis defined on the sparse matrix L.
L | the sparse square matrix. |
K | the degree of the last polynomial, i.e. the K+1 first polynomials are built. |
basis_name | 'chebyshev', and others yet to come. |
'T0',matrix | (optional): a sparse matrix to replace the identity as a 0-degree polynomial of the basis. |
'dev',str | (optional): the computing device ('cpu' or 'gpu'). |
'dtype',str | (optional): to decide in which data type the resulting Faust will be encoded ('float' or 'double' by default). |
F | the Faust of the basis composed of the K+1 orthogonal polynomials. |
Example
By default, the 0-degree polynomial is the identity. However it is possible to replace the corresponding matrix by any sparse matrix T0 of your choice (with the only constraint that size(T0,1) == size(L, 1)). In that purpose, do as follows:
function matfaust::poly::expm_multiply | ( | A | , |
B | , | ||
t | , | ||
varargin | |||
) |
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 sparse matrix). |
B | the matrix or vector to be multiplied by the matrix exponential of A. |
t | (real array) time points. |
'K',integer | (default value is 10) 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 | (optional): '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 rel_err or the size of A and B. |
'dev',str | (optional): the computing device ('cpu' or 'gpu'). |
'dtype',str | (optional): to decide in which data type the resulting array C will be encoded ('float' or 'double' by default). |
C | the approximate of e^{t_k A} B. C is a tridimensional array of size (sizef(A,1), size(B,2), size(t, 1)), each slice C(:,:,i) is the action of the matrix exponentatial of A on B according to the time point t(i). |
Example
see also matlab builtin expm
function matfaust::poly::next | ( | F | ) |
Gives the next Faust basis of dimension (n+1) from the Faust F polynomial basis of dimension n.
F | The polynomial basis Faust (must have been generated with matfaust.poly.basis). @reval G the basis of dimension (n+1) with one additional factor added to those of F. |
Example
function matfaust::poly::poly | ( | coeffs | , |
basis | , | ||
varargin | |||
) |
Computes the linear combination of the polynomials defined by basis.
coeffs | the linear combination coefficients (vector). |
basis | either the name of the polynomial basis to build on L or the basis if already built externally (as a Faust or an equivalent full array). |
'L',matrix | the sparse matrix on which the polynomial basis is built if basis is not already a Faust or a full array. |
'X',matrix | if X is set, 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 without X set). |
'dev',str | (optional): the computating device ('cpu' or 'gpu'). |
'dtype',str | (optional): to decide in which data type the resulting Faust or array will be encoded ('float' or 'double' by default). If basis is a Faust or an array its dtype/class is prioritary over this parameter which is in fact useful only if basis is the name of the basis (a str/char array). |
LC | The linear combination Faust or full array depending on if basis is itself a Faust or a np.ndarray. |
Example
Which is equivalent to do as below (in two times):
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.
But of course they are equal: