inline bool check_consistent_sizes(const char* function, const T1& x1, const T2& x2, const char* name1, const char* name2, T_result* result) { return check_consistent_sizes(function,x1,x2,name1,name2, result,default_policy()); }
/** * Construct a precomputed vari with the specified value, * operands, and gradients. * * @param[in] val The value of the variable. * @param[in] vars Vector of operands. * @param[in] gradients Vector of partial derivatives of value * with respect to operands. * @throws std::invalid_argument if the sizes of the vectors * don't match. */ precomputed_gradients_vari(double val, const std::vector<var>& vars, const std::vector<double>& gradients) : vari(val), size_(vars.size()), varis_(ChainableStack::memalloc_ .alloc_array<vari*>(vars.size())), gradients_(ChainableStack::memalloc_ .alloc_array<double>(vars.size())) { check_consistent_sizes("precomputed_gradients_vari", "vars", vars, "gradients", gradients); for (size_t i = 0; i < vars.size(); ++i) varis_[i] = vars[i].vi_; std::copy(gradients.begin(), gradients.end(), gradients_); }