The habitat membership matrix, \(\cal N\), holds information about the patch location of each habitat. It is part of the egg-laying and emergence interface, making it possible to compute egg laying from patches to habitats; and emergence from habitats to patches.
create_habitat_matrix(nPatches, membership)
the habitat membership matrix, denoted \(\cal N\) where \(\left|\cal N\right|= n_p \times n_q\)
Information about the patch location of each habitat is passed as the membership vector, an ordered list of patch locations. If the \(i^{th}\) habitat is in the \(j^{th}\) patch, then \({\cal N}_{j,i}=1.\) Otherwise, \({\cal N}_{j,i}=0.\)
Since \(\cal N\) is a matrix, it is readily used for computation. Let:
\(n_q = \) nHabitats
, the number of habitats;
\(n_p = \) nPatches
, the number of patches.
If \(w\) is any vector describing a quantity in habitats (i.e., \(\left|w\right|= n_q\)), then $$W={\cal N}\cdot w$$ is a vector that has summed \(w\) by patch, and \(\left|W\right|= n_p\).
create_habitat matrix is called by make_xds_template()
and setup_EGG_LAYING()
create_habitat_matrix(3, c(1,1,2,2,2))
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 1 1 0 0 0
#> [2,] 0 0 1 1 1
#> [3,] 0 0 0 0 0