n <- 10
n2 <- n^2
abu <- matrix(1:n2, nrow = n, ncol = n)
suitab <- matrix(1, nrow = n, ncol = n)
kernel <- calculate_dispersal_kernel(
max_dispersal_dist = 4,
kfun = negative_exponential_function,
mean_dispersal_dist = 1.2
)
res1 <- dispersal(
dispersal_kernel = kernel,
abundance = abu
)
res2 <- dispersal(
dispersal_kernel = kernel,
abundance = abu,
weights = suitab
)
stopifnot(sum(res1) - sum(res2) < 0.01)
# Note that the abundance is modified in place, i.e:
stopifnot(sum(abu - res2) < 0.01)
Run the code above in your browser using DataLab