Given two functions, f and g, that map from 2D space to 1D, and values of f and g represented as im
objects
then innerprod.im
computes the (function space) inner product
$$\int f(v) g(v) dv.$$
innerprod.im(
A,
B,
outsideA = NA,
outsideB = NA,
na.replace = TRUE,
method = "cubature"
)
If the inner product can be computed then returns sum(A
* B
), otherwise returns NA
.
An im
object containing function values representing function \(f\).
An im
object containing function values representing function \(g\).
The value of \(f\) outside the domain of A
. Typically will be 0 or NA. Default is NA.
The value of \(g\) outside the domain of B
. Typically will be 0
or NA
. Default is NA
.
Logical. If TRUE NA values in A
and B
are replaced by outsideA
and outsideB
, respectively. This allows the cubature integration to be performed (roughly) twice as quickly.
Either "cubature" or "harmonisesum". The former uses cubature::cubintegrate()
,
the latter harmonises the images using spatstat.geom::as.mask()
and sums the product of A
and B
.
This function uses the package cubature to integrate the multiple of the two images. If cubature is not available then it harmonises the two input images, multiplies them together and returns the
integral of the resulting image.
outsideA
and outsideB
are used to determine result if the inner product requires
values outside the domain of A or B. For example if outsideA=0
and the
domain of B
is larger than A
's domain then the inner product
can still be computed. However if A
is NA
outside (e.g. not
known/not provided) and the domain of B
is larger than A
's
domain then the inner product can not be computed and the returned value is NA
The harmonisesum
method appears to perform well when used by gblcc()
, but produces numerical artefacts when used by gblc()
and gblg()
. The cubature
method takes longer to compute and is more accurate for functions (A or B) that are non-zero for large vectors. This makes it suitable for use by gblc()
and gblg()
.
xi <- heather$coarse
covar <- plugincvc(xi, Frame(xi))
B <- setcov(square(1))
innerprod.im(covar, B, outsideB = 0)
Run the code above in your browser using DataLab