![]() |
Stan Math Library
5.0.0
Automatic Differentiation
|
A variable implementation taking a sequence of operands and partial derivatives with respect to the operands.
Stan users should use function precomputed_gradients() directly.
ContainerOperands | tuple of any container operands ((optionally std vector of) var_value containing Eigen types) |
ContainerGradients | tuple of any container gradients (Eigen types) |
Definition at line 29 of file precomputed_gradients.hpp.
#include <precomputed_gradients.hpp>
Public Member Functions | |
template<typename... ContainerOps, typename... ContainerGrads> | |
precomputed_gradients_vari_template (double val, size_t size, vari **varis, double *gradients, const std::tuple< ContainerOps... > &container_operands=std::tuple<>(), const std::tuple< ContainerGrads... > &container_gradients=std::tuple<>()) | |
Construct a precomputed vari with the specified value, operands, gradients and optionally container operands and containers of gradients. | |
template<typename Arith , typename VecVar , typename VecArith , typename... ContainerOps, typename... ContainerGrads, require_all_vector_t< VecVar, VecArith > * = nullptr> | |
precomputed_gradients_vari_template (Arith val, const VecVar &vars, const VecArith &gradients, const std::tuple< ContainerOps... > &container_operands=std::tuple<>(), const std::tuple< ContainerGrads... > &container_gradients=std::tuple<>()) | |
Construct a precomputed vari with the specified value, operands, gradients and optionally container operands and containers of gradients. | |
void | chain () |
Implements the chain rule for this variable, using the prestored operands and gradient. | |
Protected Member Functions | |
template<size_t... Is> | |
void | check_sizes (std::index_sequence< Is... >) |
Checks that sizes of containers in container operands and container_gradients match. | |
Protected Attributes | |
const size_t | size_ |
vari ** | varis_ |
double * | gradients_ |
ContainerOperands | container_operands_ |
ContainerGradients | container_gradients_ |
Static Protected Attributes | |
static constexpr size_t | N_containers = std::tuple_size<ContainerOperands>::value |
Private Member Functions | |
template<typename Op , typename Grad , require_all_not_std_vector_t< Op, Grad > * = nullptr> | |
void | chain_one (Op &op, const Grad &grad) |
Implements the chain rule for one non-std::vector operand. | |
template<typename Op , typename OpAlloc , typename Grad , typename GradAlloc > | |
void | chain_one (const std::vector< Op, OpAlloc > &op, const std::vector< Grad, GradAlloc > &grad) |
Implements the chain rule for one std::vector operand. | |