1 #ifndef CWISEUNARYOPERATOR_H
2 #define CWISEUNARYOPERATOR_H
5 #include <stan/math/fwd/scal.hpp>
14 template<double (*T1)(double),
15 stan::math::fvar<double> (*T2)(stan::math::fvar<double>
const&),
16 stan::math::fvar<stan::math::fvar<double>> (*T3)(stan::math::fvar<stan::math::fvar<double>>
const&)>
33 className.erase(className.size()-1,className.size());
36 ss <<
"CwiseUnaryOperator_" << className <<
"_" << id;
48 outputs.at(0).resize(inputSizes(0));
49 for(
int i=0; i<inputSizes(0); ++i)
50 outputs.at(0)(i) = T1(in.at(0).get()(i));
57 jacobian = Eigen::MatrixXd::Zero(inputSizes(0), inputSizes(0));
58 for(
int i=0; i<inputSizes(0); ++i){
59 stan::math::fvar<double> x(in.at(0).get()(i), 1.0);
60 jacobian(i,i) = T2(x).tangent();
67 Eigen::VectorXd
const& sens)
override
69 gradient.resize(inputSizes(0));
70 for(
int i=0; i<inputSizes(0); ++i){
71 stan::math::fvar<double> x(in.at(0).get()(i), 1.0);
72 gradient(i) = sens(i)*T2(x).tangent();
79 Eigen::VectorXd
const& vec)
override
81 jacobianAction.resize(inputSizes(0));
82 for(
int i=0; i<inputSizes(0); ++i){
83 stan::math::fvar<double> x(in.at(0).get()(i), 1.0);
84 jacobianAction(i) = vec(i)*T2(x).tangent();
92 Eigen::VectorXd
const& sens,
93 Eigen::VectorXd
const& vec)
override
95 hessAction.resize(inputSizes(0));
100 for(
int i=0; i<inputSizes(0); ++i){
101 stan::math::fvar<double> x(in.at(0).get()(i), 1.0);
102 hessAction(i) = vec(i)*T2(x).tangent();
106 for(
int i=0; i<inputSizes(0); ++i){
107 stan::math::fvar<stan::math::fvar<double>> x(stan::math::fvar<double>(in.at(0).get()(i), 1.0),1.0);
108 hessAction(i) = sens(i)*vec(i)*T3(x).tangent().tangent();
virtual void GradientImpl(unsigned int outWrt, unsigned int inWrt, ref_vector< Eigen::VectorXd > const &in, Eigen::VectorXd const &sens) override
virtual std::string CreateName() const override
virtual void JacobianImpl(unsigned int outWrt, unsigned int inWrt, ref_vector< Eigen::VectorXd > const &in) override
virtual void EvaluateImpl(ref_vector< Eigen::VectorXd > const &in) override
virtual void ApplyHessianImpl(unsigned int outWrt, unsigned int inWrt1, unsigned int inWrt2, ref_vector< Eigen::VectorXd > const &in, Eigen::VectorXd const &sens, Eigen::VectorXd const &vec) override
virtual void ApplyJacobianImpl(unsigned int outWrt, unsigned int inWrt, ref_vector< Eigen::VectorXd > const &in, Eigen::VectorXd const &vec) override
CwiseUnaryOperator(unsigned int dim)
Provides an abstract interface for defining vector-valued model components.
CwiseUnaryOperator< std::sin, stan::math::sin, stan::math::sin > SinOperator
CwiseUnaryOperator< std::erfc, stan::math::erfc, stan::math::erfc > ErfcOperator
CwiseUnaryOperator< stan::math::inv_Phi, stan::math::inv_Phi, stan::math::inv_Phi > InvPhiOperator
CwiseUnaryOperator< stan::math::Phi, stan::math::Phi, stan::math::Phi > PhiOperator
CwiseUnaryOperator< std::tan, stan::math::tan, stan::math::tan > TanOperator
CwiseUnaryOperator< std::ceil, stan::math::ceil, stan::math::ceil > CeilOperator
CwiseUnaryOperator< std::tgamma, stan::math::tgamma, stan::math::tgamma > TgammaOperator
CwiseUnaryOperator< std::sinh, stan::math::sinh, stan::math::sinh > SinhOperator
CwiseUnaryOperator< std::exp, stan::math::exp, stan::math::exp > ExpOperator
CwiseUnaryOperator< std::acos, stan::math::acos, stan::math::acos > AcosOperator
CwiseUnaryOperator< std::floor, stan::math::floor, stan::math::floor > FloorOperator
CwiseUnaryOperator< std::tanh, stan::math::tanh, stan::math::tanh > TanhOperator
CwiseUnaryOperator< std::atan, stan::math::atan, stan::math::atan > AtanOperator
CwiseUnaryOperator< stan::math::inv, stan::math::inv, stan::math::inv > InvOperator
CwiseUnaryOperator< std::erf, stan::math::erf, stan::math::erf > ErfOperator
CwiseUnaryOperator< std::cosh, stan::math::cosh, stan::math::cosh > CoshOperator
CwiseUnaryOperator< std::cbrt, stan::math::cbrt, stan::math::cbrt > CbrtOperator
CwiseUnaryOperator< stan::math::lgamma, stan::math::lgamma, stan::math::lgamma > LogGammaOperator
CwiseUnaryOperator< std::cos, stan::math::cos, stan::math::cos > CosOperator
CwiseUnaryOperator< std::log10, stan::math::log10, stan::math::log10 > Log10Operator
CwiseUnaryOperator< std::atanh, stan::math::atanh, stan::math::atanh > AtanhOperator
CwiseUnaryOperator< stan::math::log_inv_logit, stan::math::log_inv_logit, stan::math::log_inv_logit > LogInvLogitOperator
CwiseUnaryOperator< stan::math::square, stan::math::square, stan::math::square > SquareOperator
CwiseUnaryOperator< stan::math::trigamma, stan::math::trigamma, stan::math::trigamma > TrigammaOperator
CwiseUnaryOperator< std::abs, stan::math::abs, stan::math::abs > AbsOperator
CwiseUnaryOperator< std::asin, stan::math::asin, stan::math::asin > AsinOperator
CwiseUnaryOperator< stan::math::digamma, stan::math::digamma, stan::math::digamma > DigammaOperator
CwiseUnaryOperator< stan::math::inv_logit, stan::math::inv_logit, stan::math::inv_logit > InvLogitOperator
CwiseUnaryOperator< std::round, stan::math::round, stan::math::round > RoundOperator
CwiseUnaryOperator< stan::math::logit, stan::math::logit, stan::math::logit > LogitOperator
CwiseUnaryOperator< std::sqrt, stan::math::sqrt, stan::math::sqrt > SqrtOperator
CwiseUnaryOperator< stan::math::inv_square, stan::math::inv_square, stan::math::inv_square > InvSquareOperator
std::vector< std::reference_wrapper< const T > > ref_vector
A vector of references to something ...
CwiseUnaryOperator< std::log2, stan::math::log2, stan::math::log2 > Log2Operator
CwiseUnaryOperator< stan::math::inv_sqrt, stan::math::inv_sqrt, stan::math::inv_sqrt > InvSqrtOperator
CwiseUnaryOperator< std::log, stan::math::log, stan::math::log > LogOperator
std::vector< std::string > Split(std::string str, char delim=',')
Split a string into parts based on a particular character delimiter. Also Strips whitespace from part...
std::string demangle(const char *name)