Gets the growth rates of each species on each resource, given resource concentrations. These must be combined, according to whether the resouces are essential or substitutable, to get the overall growth rate for each species.

get_funcresp(funcresp_obj, spnum, resources, params)

Arguments

funcresp_obj

An object of class rescomp_funcresp.

spnum

The number of species.

resources

A vector of resource concentrations.

params

A list of time-dependent parameters.

Value

A matrix of species growth rates on each resource, with spnum rows and length(resources) columns.

Details

This function is normally only for internal use, but is exported to aid users in debugging their created rescomp_funcresp objects.

Examples

funcresp <- funcresp_custom(
  function(resources, params) {
    growth_rates <- params$scale * c(0.2, 0.3)
    outer(growth_rates, resources)
  },
  spnum = 2
)
get_funcresp(funcresp, 2, c(1, 4, 5, 6), list(scale = 2))
#>      [,1] [,2] [,3] [,4]
#> [1,]  0.4  1.6    2  2.4
#> [2,]  0.6  2.4    3  3.6
get_funcresp(funcresp, 2, 0.7, list(scale = 0.5))
#>       [,1]
#> [1,] 0.070
#> [2,] 0.105
try(get_funcresp(funcresp, 3, 0.7, list(scale = 0.5)))
#> Error in get_funcresp(funcresp, 3, 0.7, list(scale = 0.5)) : 
#>   `func` of `funcresp_custom` must return a matrix matching expected
#> dimensions.
#>  It returned a matrix with dimensions 2, 1.
#>  Expected dimensions were 3, 1 (i.e. `spnum` by `resnum`).