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 'inla.mesh.1d'
fm_basis(x, ...)
# S3 method for class 'inla.mesh'
fm_basis(x, ...)
# S3 method for class 'fm_evaluator'
fm_basis(x, ..., full = FALSE)
# S3 method for class 'fm_basis'
fm_basis(x, ..., full = FALSE)
# S3 method for class 'fm_tensor'
fm_basis(x, loc, weights = NULL, ..., full = FALSE)
Arguments
- x
fm_tensor()
object- ...
Passed on to submethods
- full
logical; if
TRUE
, return afm_basis
object, containing at least a projection matrixA
and logical vectorok
indicating which evaluations are valid. IfFALSE
, return only the projection matrixA
. Default isFALSE
.- loc
A location/value information object (vector, matrix,
sf
, 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
.
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
;
u(loc_i)=sum_j A_ij w_i
Methods (by class)
fm_basis(fm_mesh_1d)
: Thefm_basis
object contains additional derivative weight matrices,d1A
andd2A
,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=TRUE
output: Derivative weight matricesdx
,dy
,dz
;du/dx(loc_i)=sum_j dx_ij w_i
, etc.
Examples
# Compute basis mapping matrix
str(fm_basis(fmexample$mesh, fmexample$loc))
#> Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
#> ..@ i : int [1:30] 1 9 3 7 8 5 0 6 4 2 ...
#> ..@ p : int [1:280] 0 0 0 0 0 0 0 0 0 0 ...
#> ..@ Dim : int [1:2] 10 279
#> ..@ Dimnames:List of 2
#> .. ..$ : NULL
#> .. ..$ : NULL
#> ..@ x : num [1:30] 0.3065 0.0477 0.0831 0.6947 0.4188 ...
#> ..@ factors : list()
print(fm_basis(fmexample$mesh, fmexample$loc), full = TRUE)
#> <S4 Type Object>
#> attr(,"i")
#> [1] 1 9 3 7 8 5 0 6 4 2 3 1 5 1 0 3 9 5 0 6 6 7 8 2 4 2 4 9 7 8
#> attr(,"p")
#> [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> [26] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> [51] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> [76] 0 0 0 0 0 0 0 0 0 1 2 2 2 3 5 5 5 5 5 5 5 5 6 6 6
#> [101] 6 6 6 7 7 7 7 7 7 7 7 8 9 9 10 10 10 10 10 10 10 10 10 10 10
#> [126] 11 11 11 11 11 12 12 13 13 13 13 13 13 13 13 13 13 13 13 14 14 14 14 14 15
#> [151] 15 15 15 15 15 15 15 15 15 15 15 15 16 16 16 16 16 16 17 17 18 18 19 19 20
#> [176] 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 24 24 25
#> [201] 26 26 26 26 26 26 26 26 26 26 26 26 26 27 28 30 30 30 30 30 30 30 30 30 30
#> [226] 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
#> [251] 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
#> [276] 30 30 30 30 30
#> attr(,"Dim")
#> [1] 10 279
#> attr(,"Dimnames")
#> attr(,"Dimnames")[[1]]
#> NULL
#>
#> attr(,"Dimnames")[[2]]
#> NULL
#>
#> attr(,"x")
#> [1] 0.30649174 0.04765979 0.08314353 0.69474011 0.41877998 0.02530602
#> [7] 0.03552982 0.33316542 0.02108322 0.21657062 0.58669638 0.13670741
#> [13] 0.41395969 0.55680084 0.89457972 0.33016010 0.91911732 0.56073430
#> [19] 0.06989045 0.36303944 0.30379514 0.27939227 0.37184709 0.48518787
#> [25] 0.62452377 0.29824151 0.35439301 0.03322289 0.02586761 0.20937293
#> attr(,"factors")
#> list()
#> attr(,"class")
#> [1] "dgCMatrix"
#> attr(,"class")attr(,"package")
#> [1] "Matrix"