1 #ifndef STAN_MATH_REV_MAT_FUN_DOT_SELF_HPP 2 #define STAN_MATH_REV_MAT_FUN_DOT_SELF_HPP 22 template <
typename Derived>
25 v_ =
reinterpret_cast<vari**
>(
27 for (
size_t i = 0; i <
size_; i++)
30 template <
int R,
int C>
33 v_ =
reinterpret_cast<vari**
>(
35 for (
size_t i = 0; i <
size_; ++i)
38 inline static double square(
double x) {
return x * x; }
41 for (
size_t i = 0; i <
size; ++i)
45 template <
typename Derived>
48 for (
int i = 0; i < v.size(); ++i)
49 sum +=
square(v(i).vi_->val_);
52 template <
int R,
int C>
53 inline static double var_dot_self(
const Eigen::Matrix<var, R, C>& v) {
55 for (
int i = 0; i < v.size(); ++i)
56 sum +=
square(v(i).vi_->val_);
60 for (
size_t i = 0; i <
size_; ++i)
75 template <
int R,
int C>
fvar< T > sum(const std::vector< fvar< T > > &m)
Return the sum of the entries of the specified standard vector.
virtual void chain()
Apply the chain rule to this variable based on the variables on which it depends. ...
dot_self_vari(const Eigen::Matrix< var, R, C > &v)
dot_self_vari(vari **v, size_t size)
The variable implementation base class.
void check_vector(const char *function, const char *name, const Eigen::Matrix< T, R, C > &x)
Check if the matrix is either a row vector or column vector.
static double var_dot_self(vari **v, size_t size)
static STAN_THREADS_DEF AutodiffStackStorage * instance_
Independent (input) and dependent (output) variables for gradients.
fvar< T > dot_self(const Eigen::Matrix< fvar< T >, R, C > &v)
const double val_
The value of this variable.
static double var_dot_self(const Eigen::Matrix< var, R, C > &v)
double var_dot_self(const Eigen::DenseBase< Derived > &v)
dot_self_vari(const Eigen::DenseBase< Derived > &v)
int size(const std::vector< T > &x)
Return the size of the specified standard vector.
double adj_
The adjoint of this variable, which is the partial derivative of this variable with respect to the ro...
static double square(double x)
void * alloc(size_t len)
Return a newly allocated block of memory of the appropriate size managed by the stack allocator...