1 #ifndef STAN_MATH_REV_CORE_GEVV_VVV_VARI_HPP 2 #define STAN_MATH_REV_CORE_GEVV_VVV_VARI_HPP 19 const var* v2,
int stride2,
size_t length,
22 for (
size_t i = 0; i <
length; i++)
23 result += v1[i * stride1].vi_->
val_ * v2[i * stride2].
vi_->
val_;
25 return alpha->vi_->
val_ * result;
30 int stride2,
size_t length)
31 :
vari(
eval_gevv(alpha, v1, stride1, v2, stride2, length, &dotval_)),
36 2 * length_ *
sizeof(
vari*)));
38 for (
size_t i = 0; i <
length_; i++)
39 v1_[i] = v1[i * stride1].vi_;
40 for (
size_t i = 0; i <
length_; i++)
41 v2_[i] = v2[i * stride2].vi_;
45 const double adj_alpha =
adj_ * alpha_->
val_;
46 for (
size_t i = 0; i <
length_; i++) {
47 v1_[i]->
adj_ += adj_alpha * v2_[i]->
val_;
48 v2_[i]->
adj_ += adj_alpha * v1_[i]->
val_;
gevv_vvv_vari(const var *alpha, const var *v1, int stride1, const var *v2, int stride2, size_t length)
The variable implementation base class.
size_t length(const std::vector< T > &x)
Returns the length of the provided std::vector.
static STAN_THREADS_DEF AutodiffStackStorage * instance_
Independent (input) and dependent (output) variables for gradients.
const double val_
The value of this variable.
static double eval_gevv(const var *alpha, const var *v1, int stride1, const var *v2, int stride2, size_t length, double *dotprod)
vari * vi_
Pointer to the implementation of this variable.
double adj_
The adjoint of this variable, which is the partial derivative of this variable with respect to the ro...
void * alloc(size_t len)
Return a newly allocated block of memory of the appropriate size managed by the stack allocator...
void chain()
Apply the chain rule to this variable based on the variables on which it depends. ...