Computes the basis mapping matrix between a function space on a mesh, and locations.
Usage
fm_basis(x, ..., full = FALSE)
# Default S3 method
fm_basis(x, ..., full = FALSE)
# S3 method for class 'fm_mesh_1d'
fm_basis(x, loc, weights = NULL, derivatives = NULL, ..., full = FALSE)
# S3 method for class 'fm_mesh_2d'
fm_basis(x, loc, weights = NULL, derivatives = NULL, ..., full = FALSE)
# S3 method for class 'fm_mesh_3d'
fm_basis(x, loc, weights = NULL, ..., full = FALSE)
# S3 method for class 'fm_lattice_2d'
fm_basis(x, loc, weights = NULL, ..., full = FALSE)
# S3 method for class 'fm_lattice_Nd'
fm_basis(x, loc, weights = NULL, ..., full = FALSE)
# S3 method for class 'fm_tensor'
fm_basis(x, loc, weights = NULL, ..., full = FALSE)
# S3 method for class 'fm_collect'
fm_basis(x, loc, weights = NULL, ..., full = FALSE)
# S3 method for class 'matrix'
fm_basis(x, ok = NULL, weights = NULL, ..., full = FALSE)
# S3 method for class 'Matrix'
fm_basis(x, ok = NULL, weights = NULL, ..., full = FALSE)
# S3 method for class 'list'
fm_basis(x, weights = NULL, ..., full = FALSE)
# S3 method for class 'fm_basis'
fm_basis(x, ..., full = FALSE)
# S3 method for class 'fm_evaluator'
fm_basis(x, ..., full = FALSE)Arguments
- x
An function space object, or other supported object (
matrix,Matrix,list)- ...
Passed on to submethods
- full
logical; if
TRUE, return afm_basisobject, containing at least a projection matrixAand logical vectorokindicating which evaluations are valid. IfFALSE, return only the projection matrixA. Default isFALSE.- loc
A location/value information object (
numeric,matrix,sf,fm_bary, etc, depending on the class ofx)- weights
Optional weight vector to apply (from the left, one weight for each row of the basis matrix)
- derivatives
If non-NULL and logical, include derivative matrices in the output. Forces
full = TRUE.- ok
numerical of length
NROW(x), indicating which rows ofxare valid/successful basis evaluations. IfNULL, inferred asrep(TRUE, NROW(x)).
Value
A sparseMatrix object (if full = FALSE), or a fm_basis object
(if full = TRUE or isTRUE(derivatives)). The fm_basis object contains
at least the projection matrix A and logical vector ok; If x_j
denotes the latent basis coefficient for basis function j, the field is
defined as u(loc_i)=sum_j A_ij x_j for all i where ok[i] is TRUE,
and u(loc_i)=0.0 where ok[i] is FALSE.
Methods (by class)
fm_basis(fm_mesh_1d): Ifderivatives=TRUE, thefm_basisobject contains additional derivative weight matrices,d1Aandd2A,du/dx(loc_i)=sum_j dx_ij w_i.fm_basis(fm_mesh_2d): Ifderivatives=TRUE, additional derivative weight matrices are included in thefull=TRUEoutput: Derivative weight matricesdx,dy,dz;du/dx(loc_i)=sum_j dx_ij w_i, etc.fm_basis(fm_mesh_3d):fm_mesh_3dbasis functions.fm_basis(fm_lattice_2d):fm_lattice_2dbilinear basis functions.fm_basis(fm_lattice_Nd):fm_lattice_Ndmultilinear basis functions.fm_basis(fm_tensor): Evaluates a basis matrix for afm_tensorfunction space.fm_basis(fm_collect): Evaluates a basis matrix for afm_collectfunction space. Thelocargument must be alistortibblewith elementsloc(the locations) andindex(the indices into the function space collection).fm_basis(matrix): Creates a newfm_basisobject with elementsAandok, from a pre-evaluated basis matrix, including optional additional elements in the...arguments. If aokisNULL, it is inferred asrep(TRUE, NROW(x)), indicating that all rows correspond to successful basis evaluations. Iffull = FALSE, returns the matrix unchanged.fm_basis(Matrix): Creates a newfm_basisobject with elementsAandok, from a pre-evaluated basis matrix, including optional additional elements in the...arguments. If aokisNULL, it is inferred asrep(TRUE, NROW(x)), indicating that all rows correspond to successful basis evaluations. Iffull = FALSE, returns the matrix unchanged.fm_basis(list): Creates a newfm_basisobject from a plain list containing at least an elementA. If anokelement is missing, it is inferred asrep(TRUE, NROW(x$A)). Iffull = FALSE, extracts theAmatrix.fm_basis(fm_basis): IffullisTRUE, returnsxunchanged, otherwise returns theAmatrix contained inx.fm_basis(fm_evaluator): Extractfm_basisinformation from anfm_evaluatorobject. Iffull = FALSE, returns theAmatrix contained in thefm_basisobject.
Examples
# Compute basis mapping matrix
dim(fm_basis(fmexample$mesh, fmexample$loc))
#> [1] 10 279
print(fm_basis(fmexample$mesh, fmexample$loc, full = TRUE))
#> fm_basis object
#> Projection matrix (A): 10-by-279
#> Valid evaluations (ok): 10 out of 10
#> Additional information: bary
# From precomputed `fm_bary` information:
bary <- fm_bary(fmexample$mesh, fmexample$loc)
print(fm_basis(fmexample$mesh, bary, full = TRUE))
#> fm_basis object
#> Projection matrix (A): 10-by-279
#> Valid evaluations (ok): 10 out of 10
#> Additional information: bary