Assembly Module¶
- ammorph.assembly.assemble(rbffunc, points, polynomial_order=None, out=None)¶
Assemble the M matrix for computing the RBF weights.
Assembles the matrix
\[\begin{split}M = \begin{bmatrix} A & P^T \\ P & 0 \end{bmatrix}\end{split}\]with
\[\begin{split}A = \begin{bmatrix} \phi(h_1 - h_1) & \phi(h_1 - h_2) & \ldots & \phi(h_1 - h_N) \\ \phi(h_2 - h_1) & \phi(h_2 - h_2) & \ldots & \phi(h_2 - h_N) \\ & \vdots & & \\ \phi(h_N - h_1) & \phi(h_N - h_2) & \ldots & \phi(h_N - h_N) \\ \end{bmatrix}\end{split}\]and
\[\begin{split}P = \begin{bmatrix} 1 & 1 & \ldots & 1 \\ x_1 & x_2 & \ldots & x_N \\ y_1 & y_2 & \ldots & y_N \\ z_1 & z_2 & \ldots & z_N \\ x_1^2 & x_2^2 & \ldots & x_N^2 & \ldots & & \end{bmatrix}\end{split}\]\(P\) contains monomials up to order of argument function argument polynomial_order. If polynomial_order is None, \(A\) is not augmented by any \(P\) matrix. The augmentation with \(P\) is useful for radial basis functions that would lead to a singular matrix \(A\). The augmentation makes \(M\) positive definite for these functions.
- Parameters
rbffunc (str) – String that defines the rbf function \(\phi(r)\) used for assembly. The function string must contain the character ‘r’ as argument.
points (array_like) – point coordinates of the handle points \(h_i\) for assembly. points is an array of dimension \(N_H \times d\) where \(N_H\) is the number of handle points and \(d\) is the spatial dimension.
polynomial_order (int, optional) – The interpolation problem is augmented by polynomial terms of order polynomial_order. Currently only up to order 1 is supported. If None, no polynomial terms are added. If zero, only the term ‘1’ is added.
out (array_like, optional) – Array to write the matrix \(M\) into.
- Returns
matrix – Assembled matrix.
- Return type
array_like
- ammorph.assembly.sparse_assemble(rbffunc, points, polynomial_order=None)¶
Assemble the M matrix for computing the RBF weights as sparse matrix.
Compares to the assemble routine, this is a sparse assembly and used with Radial Basis Functions with compact support.
Assembles the matrix
\[\begin{split}M = \begin{bmatrix} A & P^T \\ P & 0 \end{bmatrix}\end{split}\]with
\[\begin{split}A = \begin{bmatrix} \phi(h_1 - h_1) & \phi(h_1 - h_2) & \ldots & \phi(h_1 - h_N) \\ \phi(h_2 - h_1) & \phi(h_2 - h_2) & \ldots & \phi(h_2 - h_N) \\ & \vdots & & \\ \phi(h_N - h_1) & \phi(h_N - h_2) & \ldots & \phi(h_N - h_N) \\ \end{bmatrix}\end{split}\]and
\[\begin{split}P = \begin{bmatrix} 1 & 1 & \ldots & 1 \\ x_1 & x_2 & \ldots & x_N \\ y_1 & y_2 & \ldots & y_N \\ z_1 & z_2 & \ldots & z_N \\ x_1^2 & x_2^2 & \ldots & x_N^2 & \ldots & & \end{bmatrix}\end{split}\]\(P\) contains monomials up to order of argument function argument polynomial_order. If polynomial_order is None, \(A\) is not augmented by any \(P\) matrix. The augmentation with \(P\) is useful for radial basis functions that would lead to a singular matrix \(A\). The augmentation makes \(M\) positive definite for these functions.
- Parameters
rbffunc (str) – String that defines the rbf function \(\phi(r)\) used for assembly. The function string must contain the character ‘r’ as argument.
points (array_like) – point coordinates of the handle points \(h_i\) for assembly. points is an array of dimension \(N_H \times d\) where \(N_H\) is the number of handle points and \(d\) is the spatial dimension.
polynomial_order (int, optional) – The interpolation problem is augmented by polynomial terms of order polynomial_order. Currently only up to order 1 is supported. If None, no polynomial terms are added. If zero, only the term ‘1’ is added.
- Returns
matrix – Assembled matrix.
- Return type
csr_matrix