Stan Math Library  2.20.0
reverse mode automatic differentiation
broadcast_array.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_META_BROADCAST_ARRAY_HPP
2 #define STAN_MATH_PRIM_SCAL_META_BROADCAST_ARRAY_HPP
3 
4 #include <stdexcept>
5 
6 namespace stan {
7 namespace math {
8 namespace internal {
9 template <typename T>
11  private:
12  T& prim_;
13 
14  public:
15  explicit broadcast_array(T& prim) : prim_(prim) {}
16 
17  T& operator[](int /*i*/) { return prim_; }
18 
25  template <typename Y>
26  void operator=(const Y& m) {
27  prim_ = m[0];
28  }
29 };
30 
31 template <typename T, typename S>
33  public:
38  T& operator[](int /*i*/);
39 
43  template <typename Y>
44  void operator=(const Y& /*A*/);
45 };
46 } // namespace internal
47 } // namespace math
48 } // namespace stan
49 
50 #endif
void operator=(const Y &m)
We can assign any right hand side which allows for indexing to a broadcast_array. ...

     [ Stan Home Page ] © 2011–2018, Stan Development Team.