![]() |
Stan
2.5.0
probability, sampling & optimization
|
VectorView is a template metaprogram that takes its argument and allows it to be used like a vector. More...
#include <traits.hpp>
Public Types | |
| typedef scalar_type< T >::type | scalar_t |
Public Member Functions | |
| VectorView (scalar_t &c) | |
| VectorView (std::vector< scalar_t > &v) | |
| template<int R, int C> | |
| VectorView (Eigen::Matrix< scalar_t, R, C > &m) | |
| VectorView (scalar_t *x) | |
| scalar_t & | operator[] (int i) |
VectorView is a template metaprogram that takes its argument and allows it to be used like a vector.
There are three template parameters
For a scalar value, it broadcasts the single value when using operator[].
For a vector, operator[] looks into the value passed in. Note: this is not safe. It is possible to read past the size of an array.
Uses: Read arguments to prob functions as vectors, even if scalars, so they can be read by common code (and scalars automatically broadcast up to behave like vectors) : VectorView of immutable const array of double* (no allocation)
Build up derivatives into common storage : VectorView of mutable shared array (no allocation because allocated on auto-diff arena memory)
Definition at line 275 of file traits.hpp.
| typedef scalar_type<T>::type stan::VectorView< T, is_array, throw_if_accessed >::scalar_t |
Definition at line 277 of file traits.hpp.
|
inline |
Definition at line 279 of file traits.hpp.
|
inline |
Definition at line 281 of file traits.hpp.
|
inline |
Definition at line 284 of file traits.hpp.
|
inline |
Definition at line 286 of file traits.hpp.
|
inline |
Definition at line 288 of file traits.hpp.