innerprod.im: Inner Product of Two Functions Represented as Images

View source: R/innerprodim.R

innerprod.imR Documentation

Inner Product of Two Functions Represented as Images

Description

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.

Usage

innerprod.im(
  A,
  B,
  outsideA = NA,
  outsideB = NA,
  na.replace = TRUE,
  method = "cubature"
)

Arguments

A

An im object containing function values representing function f.

B

An im object containing function values representing function g.

outsideA

The value of f outside the domain of A. Typically will be 0 or NA. Default is NA.

outsideB

The value of g outside the domain of B. Typically will be 0 or NA. Default is NA.

na.replace

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.

method

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.

Details

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().

Value

If the inner product can be computed then returns sum(A * B), otherwise returns NA.

Examples

xi <- heather$coarse
covar <- plugincvc(xi, Frame(xi))
B <- setcov(square(1))
innerprod.im(covar, B, outsideB = 0)

lacunaritycovariance documentation built on Nov. 2, 2023, 6:08 p.m.