Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | List of all members
stan::VectorView< T, is_array, throw_if_accessed > Class Template Reference

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_toperator[] (int i)
 

Detailed Description

template<typename T, bool is_array = stan::is_vector_like<T>::value, bool throw_if_accessed = false>
class stan::VectorView< T, is_array, throw_if_accessed >

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.

Member Typedef Documentation

template<typename T, bool is_array = stan::is_vector_like<T>::value, bool throw_if_accessed = false>
typedef scalar_type<T>::type stan::VectorView< T, is_array, throw_if_accessed >::scalar_t

Definition at line 277 of file traits.hpp.

Constructor & Destructor Documentation

template<typename T, bool is_array = stan::is_vector_like<T>::value, bool throw_if_accessed = false>
stan::VectorView< T, is_array, throw_if_accessed >::VectorView ( scalar_t c)
inline

Definition at line 279 of file traits.hpp.

template<typename T, bool is_array = stan::is_vector_like<T>::value, bool throw_if_accessed = false>
stan::VectorView< T, is_array, throw_if_accessed >::VectorView ( std::vector< scalar_t > &  v)
inline

Definition at line 281 of file traits.hpp.

template<typename T, bool is_array = stan::is_vector_like<T>::value, bool throw_if_accessed = false>
template<int R, int C>
stan::VectorView< T, is_array, throw_if_accessed >::VectorView ( Eigen::Matrix< scalar_t, R, C > &  m)
inline

Definition at line 284 of file traits.hpp.

template<typename T, bool is_array = stan::is_vector_like<T>::value, bool throw_if_accessed = false>
stan::VectorView< T, is_array, throw_if_accessed >::VectorView ( scalar_t x)
inline

Definition at line 286 of file traits.hpp.

Member Function Documentation

template<typename T, bool is_array = stan::is_vector_like<T>::value, bool throw_if_accessed = false>
scalar_t& stan::VectorView< T, is_array, throw_if_accessed >::operator[] ( int  i)
inline

Definition at line 288 of file traits.hpp.


The documentation for this class was generated from the following file:

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