R/softplus.R

Defines functions d4softplus d3softplus d2softplus dsoftplus softplus

Documented in d2softplus d3softplus d4softplus dsoftplus softplus

#' Softplus Activation Function
#'
#' @param x numeric vector
#' @return numeric vector
#' @family Activation Functions
#' @export
#' @author Matthew L. Fidler
#' @examples
#'
#' softplus(c(-1, 0, 1, 2))
#'
#' \donttest{
#' # You can use rxode2 too:
#'
#' r <- rxode2({
#'  s <- softplus(time)
#' })
#'
#' e <- et(c(-1, 0, 1, 2))
#'
#' rxSolve(r, e)
#' }
#'
softplus <- function(x) {
  checkmate::assertNumeric(x, finite=TRUE, any.missing=FALSE)
  .Call(`_rxode2_activationF`, x, 3L)
}

#' Default Softplus Activation Function
#'
#' @param x numeric vector
#' @return numeric vector
#' @family Activation Functions
#' @export
#' @author Matthew L. Fidler
#' @examples
#'
#' dsoftplus(c(-1, 0, 1, 2))
#'
#' \donttest{
#' # You can use rxode2 too:
#'
#' r <- rxode2({
#'  s1 <- dsoftplus(time)
#' })
#'
#' e <- et(c(-1, 0, 1, 2))
#'
#' rxSolve(r, e)
#' }
#'
dsoftplus <- function(x) {
  checkmate::assertNumeric(x, finite=TRUE, any.missing=FALSE)
  .Call(`_rxode2_activationF`, x, 13L)
}

#' @rdname dsoftplus
d2softplus <- function(x) {
  checkmate::assertNumeric(x, finite=TRUE, any.missing=FALSE)
  .Call(`_rxode2_activationF`, x, 14L)
}

#' @rdname dsoftplus
d3softplus <- function(x) {
  checkmate::assertNumeric(x, finite=TRUE, any.missing=FALSE)
  .Call(`_rxode2_activationF`, x, 15L)
}

#' @rdname dsoftplus
d4softplus <- function(x) {
  checkmate::assertNumeric(x, finite=TRUE, any.missing=FALSE)
  .Call(`_rxode2_activationF`, x, 16L)
}

Try the rxode2 package in your browser

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

rxode2 documentation built on July 28, 2026, 5:08 p.m.