Automatic Differentiation
 
Loading...
Searching...
No Matches
broadcast_array.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUNCTOR_BROADCAST_ARRAY_HPP
2#define STAN_MATH_PRIM_FUNCTOR_BROADCAST_ARRAY_HPP
3
11#include <functional>
12#include <stdexcept>
13
14namespace stan {
15namespace math {
16namespace internal {
17
18template <typename T>
20 private:
21 std::reference_wrapper<T> prim_;
22
23 public:
24 template <typename TT>
25 explicit broadcast_array(TT&& prim) : prim_(std::forward<TT>(prim)) {}
26
27 T& operator[](int /*i*/) { return prim_.get(); }
28
34 template <typename Y>
35 void operator=(const Y& m) {
36 prim_.get() = sum(m);
37 }
38};
39
40template <typename T, typename S, typename Enable = void>
42 public:
47 constexpr T& operator[](int /*i*/);
48
52 template <typename Y>
53 constexpr void operator=(const Y& /*A*/);
54 template <typename Y>
55 constexpr void add_write_event(Y&& /* event */);
56};
57
58template <typename ViewElt, typename T>
60 enum { R = T::RowsAtCompileTime, C = T::ColsAtCompileTime };
62
63 public:
68 ViewElt& operator[](int /*i*/);
72 ViewElt& operator()(int /*i*/);
76 void operator=(const T_arg& /*A*/);
80 void operator+=(T_arg /*A*/);
84 void operator-=(T_arg /*A*/);
88 T& row(int /*i*/);
92 T& col(int /*i*/);
93};
94} // namespace internal
95} // namespace math
96} // namespace stan
97#endif
require_t< std::is_arithmetic< scalar_type_t< std::decay_t< T > > > > require_st_arithmetic
Require scalar type satisfies std::is_arithmetic.
require_t< is_eigen< std::decay_t< T > > > require_eigen_t
Require type satisfies is_eigen.
Definition is_eigen.hpp:113
ViewElt & operator()(int)
Not implemented so cannot be called.
ViewElt & operator[](int)
Not implemented so cannot be called.
void operator=(const T_arg &)
Not implemented so cannot be called.
void operator=(const Y &m)
Broadcast array can be assigned a scalar or a vector.
constexpr void operator=(const Y &)
Not implemented so cannot be called.
constexpr T & operator[](int)
Not implemented so cannot be called.
typename promote_scalar_type< std::decay_t< T >, std::decay_t< S > >::type promote_scalar_t
auto sum(const std::vector< T > &m)
Return the sum of the entries of the specified standard vector.
Definition sum.hpp:23
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
STL namespace.