R/Ops.r

setClass("perceptualRange", slots=c("type"="character", "parameters"="numeric"))
setClass("state", slots=c("turningAngleConcentration"="numeric"
	, "perceptualRange"="perceptualRange", "stepLength"="numeric"
	, "name"="character"))
setClass("species", slots=c("name"="character", "transitionMatrix"="matrix"
	, "states"="list", "resistanceMap"="ANY"))

setMethod("+", signature(e1 = "species"), function(e1, e2) {
	for(i in seq_along(e1@states)) {
		e1@states[[i]] <- callGeneric(e1@states[[i]], e2)
	}
	return(e1)
})

setMethod("*", signature(e1 = "species"), function(e1, e2) {
	for(i in seq_along(e1@states)) {
		e1@states[[i]] <- callGeneric(e1@states[[i]], e2)
	}
	return(e1)
})

setMethod("+", signature(e1 = "state", e2 = "numeric"), function(e1, e2) {
	e1@stepLength <- e2
	return(e1)
})

setMethod("*", signature(e1 = "state", e2 = "numeric"), function(e1, e2) {
	e1@perceptualRange@parameters[["radius"]] <- e2
	return(e1)
})

# Combine states for multistate movements
setMethod("+", signature(e1 = "state", e2 = "state"), function(e1, e2) {
	return(list(e1, e2))
})

setMethod("+", signature(e1 = "list", e2 = "state"), function(e1, e2) {
	return(c(e1, e2))
})

setMethod("+", signature(e1 = "state", e2 = "list"), function(e1, e2) {
	return(c(e1, e2))
})

Try the SiMRiv package in your browser

Any scripts or data that you put into this service are public.

SiMRiv documentation built on Sept. 15, 2023, 5:07 p.m.