1 #ifndef __STAN__AGRAD__REV__MATRIX__ASSIGN_HPP__
2 #define __STAN__AGRAD__REV__MATRIX__ASSIGN_HPP__
5 #include <boost/math/tools/promotion.hpp>
18 template <
typename LHS,
typename RHS>
19 struct needs_promotion {
20 enum { value = ( is_constant_struct<RHS>::value
21 && !is_constant_struct<LHS>::value) };
24 template <
bool PromoteRHS,
typename LHS,
typename RHS>
26 static inline void assign(LHS& ,
const RHS& ) {
27 throw std::domain_error(
"should not call base class of assigner");
31 template <
typename LHS,
typename RHS>
32 struct assigner<false,LHS,RHS> {
33 static inline void assign(LHS& var,
const RHS& val) {
38 template <
typename LHS,
typename RHS>
39 struct assigner<true,LHS,RHS> {
40 static inline void assign(LHS& var,
const RHS& val) {
46 template <
typename LHS,
typename RHS>
47 inline void assign(Eigen::Block<LHS>
var,
const RHS& val) {
48 assigner<needs_promotion<Eigen::Block<LHS>,RHS>::value, Eigen::Block<LHS>, RHS>
::assign(var,val);
51 template <
typename LHS,
typename RHS>
53 assigner<needs_promotion<LHS,RHS>::value, LHS, RHS>
::assign(var,val);