% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/adjointDiscrete.R
\name{.rxAdjointExpand}
\alias{.rxAdjointExpand}
\title{Build the adjoint-expansion model text for an in-engine discrete-adjoint solve}
\usage{
.rxAdjointExpand(object, calcSens, stiff = FALSE)
}
\arguments{
\item{object}{model definition accepted by \code{\link[=rxode2]{rxode2()}}.}

\item{calcSens}{character vector of parameters to differentiate w.r.t.}
}
\value{
list with \code{text} (expanded model text), \code{st}, \code{ns}, \code{np},
\code{calcSens}, and lhs layout \code{fxOff} (=0), \code{fpOff} (=ns*ns), \code{nlhsAdj}.
}
\description{
Exposes the state Jacobian \code{F_X = dF/dy} and parameter forcing
\code{F_p = dF/dtheta} as rxode2 lhs assignments spliced onto the base ODE, so the
C++ backward sweep can evaluate them at any stage state via \code{calc_lhs}.  The
lhs are emitted in a fixed order: all \code{F_X} entries row-major
(\code{rx__adjFX_i_j__} at index \code{i*ns + j}), then \code{F_p} (\code{rx__adjFP_i_p__} at
\code{ns*ns + i*np + p}).
}
\author{
Matthew L. Fidler
}
\keyword{internal}
