| Stan Math Library 2.11.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

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

Public Types | Public Member Functions | List of all members
stan::VectorView< T, is_array, throw_if_accessed > Class Template Reference

VectorView is a template expression that is constructed with a container or scalar, which it then allows to be used as an array using `operator[]`. More...

`#include <VectorView.hpp>`

## Public Types
typedef boost::conditional< boost::is_const< T >::value, typename boost::add_const< typename scalar_type< T >::type >::type, typename scalar_type< T >::type >::type | scalar_t

## Public Member Functions
template<typename X >
| VectorView (X x)
scalar_t & | operator[] (int i)
scalar_t & | operator[] (int i) const

## 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 expression that is constructed with a container or scalar, which it then allows to be used as an array using `operator[]`.

For a scalar value, any index returns the reference or pointer used to construct the view.

For a container, the index returns a reference to the position in the underlying container used to construct the view. WARNING: There is no bounds checking for container indices and they will segfault if accessed beyond their boundaries.

The first use is to 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).

The second use is to build up derivatives into common storage : VectorView of mutable shared array (no allocation because allocated on auto-diff arena memory).

Because it deals with references to its inputs, it is up to the client of VectorView to ensure that the container being wrapped is not modified while the VectorView is in use in such a way as to disrupt the indexing. Similarly, because it deals with references, it cannot be constructed with a literal or expression.

Template Parameters

  T | Type of scalar or container being wrapped.
  is_array | True if underlying type T can be indexed with operator[].
  throw_if_accessed | True if the behaviro is to throw an exception whenever `operator[]` is called.

Definition at line 48 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 boost::conditional<boost::is_const<T>::value, typename boost::add_const< typename scalar_type<T>::type>::type, typename scalar_type<T>::type>::type stan::VectorView< T, is_array, throw_if_accessed >::scalar_t

Definition at line 54 of file VectorView.hpp.

## Constructor & Destructor Documentation

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

stan::VectorView< T, is_array, throw_if_accessed >::VectorView | ( | X | x | ) |
| inlineexplicit

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

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 | ) | const
| inline

Definition at line 67 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–2016, Stan Development Team.