| Stan Math Library 2.6.3 probability, sampling & optimization

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
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 <VectorView.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)

## 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

- T: Type of the thing to be wrapped. For example, double, var, vector<double>, etc.
- is_array: Boolean variable indicating whether the underlying type is an array.
- throw_if_accessed: Boolean variable indicating whether this instance should not be used and should throw if operator[] is used.

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 41 of file VectorView.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 43 of file VectorView.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 explicit

Definition at line 45 of file VectorView.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 explicit

Definition at line 47 of file VectorView.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 explicit

Definition at line 50 of file VectorView.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 explicit

Definition at line 52 of file VectorView.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 54 of file VectorView.hpp.

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

- stan/math/prim/scal/meta/VectorView.hpp

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