CppADCodeGen  HEAD
A C++ Algorithmic Differentiation Package with Source Code Generation
CppAD::cg::ArrayView< Type > Class Template Reference
Inheritance diagram for CppAD::cg::ArrayView< Type >:
Inheritance graph
Collaboration diagram for CppAD::cg::ArrayView< Type >:
Collaboration graph

Public Types

using value_type = Type
 
using pointer = value_type *
 
using const_pointer = const value_type *
 
using reference = value_type &
 
using const_reference = const Type &
 
using iterator = value_type *
 
using const_iterator = const value_type *
 
using const_reverse_iterator = std::reverse_iterator< const_iterator >
 
using reverse_iterator = std::reverse_iterator< iterator >
 
using size_type = size_t
 
using difference_type = ptrdiff_t
 

Public Member Functions

 ArrayView ()
 
 ArrayView (pointer array, size_type n)
 
 ArrayView (std::vector< value_type > &vector)
 
 ArrayView (CppAD::vector< value_type > &vector)
 
template<std::size_t S>
 ArrayView (std::array< value_type, S > &array)
 
 ArrayView (std::valarray< value_type > &array)
 
template<class TT = Type>
 ArrayView (const ArrayView< typename std::remove_const< value_type >::type > &array, typename std::enable_if< std::is_const< TT >::value >::type *=0)
 
template<class TT = Type>
 ArrayView (const std::vector< typename std::remove_const< value_type >::type > &vector, typename std::enable_if< std::is_const< TT >::value >::type *=0)
 
template<class TT = Type>
 ArrayView (const CppAD::vector< typename std::remove_const< value_type >::type > &vector, typename std::enable_if< std::is_const< TT >::value >::type *=0)
 
template<std::size_t S, class TT = Type>
 ArrayView (const std::array< typename std::remove_const< value_type >::type, S > &array, typename std::enable_if< std::is_const< TT >::value >::type *=0)
 
template<class TT = Type>
 ArrayView (const std::valarray< typename std::remove_const< value_type >::type > &array, typename std::enable_if< std::is_const< TT >::value >::type *=0)
 
 ArrayView (const ArrayView &x)=default
 
virtual ~ArrayView ()=default
 
size_t size () const noexcept
 
size_type max_size () const noexcept
 
bool empty () const noexcept
 
pointer data () noexcept
 
const_pointer data () const noexcept
 
void fill (const value_type &u)
 
ArrayView< value_type > head (size_t n)
 
ArrayView< const value_type > head (size_t n) const
 
ArrayView< value_type > tail (size_t n)
 
ArrayView< const value_type > tail (size_t n) const
 
ArrayView< value_type > segment (size_t start, size_t n)
 
ArrayView< const value_type > segment (size_t start, size_t n) const
 
void swap (ArrayView &other) noexcept
 
iterator begin () noexcept
 
const_iterator begin () const noexcept
 
iterator end () noexcept
 
const_iterator end () const noexcept
 
reverse_iterator rbegin () noexcept
 
const_reverse_iterator rbegin () const noexcept
 
reverse_iterator rend () noexcept
 
const_reverse_iterator rend () const noexcept
 
const_iterator cbegin () const noexcept
 
const_iterator cend () const noexcept
 
const_reverse_iterator crbegin () const noexcept
 
const_reverse_iterator crend () const noexcept
 
reference operator[] (size_type i)
 
const_reference operator[] (size_type i) const
 
reference at (size_type i)
 
const_reference at (size_type i) const
 
reference front ()
 
const_reference front () const
 
reference back ()
 
const_reference back () const
 
ArrayViewoperator= (const ArrayView &x)
 
template<typename TT = const Type, typename = typename std::enable_if<!std::is_same<Type, TT>::value && std::is_assignable<Type&, TT&>::value>::type>
ArrayViewoperator= (const ArrayView< TT > &x)
 
ArrayViewoperator= (const std::vector< Type > &x)
 
ArrayViewoperator= (const CppAD::vector< Type > &x)
 

Detailed Description

template<class Type>
class CppAD::cg::ArrayView< Type >

A simple wrapper for C arrays. It does not own the data array.

Definition at line 30 of file array_view.hpp.

Constructor & Destructor Documentation

◆ ArrayView() [1/12]

template<class Type>
CppAD::cg::ArrayView< Type >::ArrayView ( )
inline

Default empty constructor for arrays with no elements

Definition at line 56 of file array_view.hpp.

Referenced by CppAD::cg::ArrayView< CppAD::cg::CG< Base > >::ArrayView().

◆ ArrayView() [2/12]

template<class Type>
CppAD::cg::ArrayView< Type >::ArrayView ( pointer  array,
size_type  n 
)
inline

Creates a wrapper for an existing array.

Parameters
arraypointer to the first element of the array
nsize of the array

Definition at line 67 of file array_view.hpp.

◆ ArrayView() [3/12]

template<class Type>
CppAD::cg::ArrayView< Type >::ArrayView ( std::vector< value_type > &  vector)
inline

Creates a wrapper from a vector. It is expected that the vector is not resized nor deleted while using this wrapper.

Parameters
vectorthe vector to wrap

Definition at line 81 of file array_view.hpp.

◆ ArrayView() [4/12]

template<class Type>
CppAD::cg::ArrayView< Type >::ArrayView ( CppAD::vector< value_type > &  vector)
inline

Creates a wrapper from a vector. It is expected that the vector is not resized nor deleted while using this wrapper.

Parameters
vectorthe vector to wrap

Definition at line 93 of file array_view.hpp.

◆ ArrayView() [5/12]

template<class Type>
template<std::size_t S>
CppAD::cg::ArrayView< Type >::ArrayView ( std::array< value_type, S > &  array)
inline

Creates a wrapper from an std::array. It is expected that std::array is not deleted while using this wrapper.

Parameters
arraythe std::array to wrap

Definition at line 105 of file array_view.hpp.

◆ ArrayView() [6/12]

template<class Type>
CppAD::cg::ArrayView< Type >::ArrayView ( std::valarray< value_type > &  array)
inline

Creates a wrapper from an std::valarray. It is expected that std::valarray is not deleted while using this wrapper.

Parameters
arraythe valarray to wrap

Definition at line 116 of file array_view.hpp.

◆ ArrayView() [7/12]

template<class Type>
template<class TT = Type>
CppAD::cg::ArrayView< Type >::ArrayView ( const ArrayView< typename std::remove_const< value_type >::type > &  array,
typename std::enable_if< std::is_const< TT >::value >::type *  = 0 
)
inline

Creates an ArrayView for a const data type from another ArrayView with a non-const data type.

Parameters
arraythe other ArrayView with a non-const data type

Definition at line 128 of file array_view.hpp.

◆ ArrayView() [8/12]

template<class Type>
template<class TT = Type>
CppAD::cg::ArrayView< Type >::ArrayView ( const std::vector< typename std::remove_const< value_type >::type > &  vector,
typename std::enable_if< std::is_const< TT >::value >::type *  = 0 
)
inline

Creates a wrapper from a vector with a non-const datd type. It is expected that the vector is not resized nor deleted while using this wrapper.

Parameters
vectorthe vector to wrap with a non-const data type

Definition at line 142 of file array_view.hpp.

◆ ArrayView() [9/12]

template<class Type>
template<class TT = Type>
CppAD::cg::ArrayView< Type >::ArrayView ( const CppAD::vector< typename std::remove_const< value_type >::type > &  vector,
typename std::enable_if< std::is_const< TT >::value >::type *  = 0 
)
inline

Creates a wrapper from a vector with a non-const data type. It is expected that the vector is not resized nor deleted while using this wrapper.

Parameters
vectorthe vector to wrap with a non-const data type

Definition at line 156 of file array_view.hpp.

◆ ArrayView() [10/12]

template<class Type>
template<std::size_t S, class TT = Type>
CppAD::cg::ArrayView< Type >::ArrayView ( const std::array< typename std::remove_const< value_type >::type, S > &  array,
typename std::enable_if< std::is_const< TT >::value >::type *  = 0 
)
inline

Creates a wrapper from a std::array with a non-const data type. It is expected that std::array is not deleted while using this wrapper.

Parameters
arraythe std::array to wrap with a non-const data type

Definition at line 169 of file array_view.hpp.

◆ ArrayView() [11/12]

template<class Type>
template<class TT = Type>
CppAD::cg::ArrayView< Type >::ArrayView ( const std::valarray< typename std::remove_const< value_type >::type > &  array,
typename std::enable_if< std::is_const< TT >::value >::type *  = 0 
)
inline

Creates a wrapper from an std::valarray with a non-const data type. It is expected that std::valarray is not deleted while using this wrapper.

Parameters
arraythe valarray to wrap with a non-const data type

Definition at line 182 of file array_view.hpp.

◆ ArrayView() [12/12]

template<class Type>
CppAD::cg::ArrayView< Type >::ArrayView ( const ArrayView< Type > &  x)
inlinedefault

Copy constructor

Parameters
x

◆ ~ArrayView()

template<class Type>
virtual CppAD::cg::ArrayView< Type >::~ArrayView ( )
virtualdefault

Member Function Documentation

◆ data() [1/2]

◆ data() [2/2]

template<class Type>
const_pointer CppAD::cg::ArrayView< Type >::data ( ) const
inlinenoexcept
Returns
raw pointer to the array

Definition at line 227 of file array_view.hpp.

◆ head() [1/2]

template<class Type>
ArrayView<value_type> CppAD::cg::ArrayView< Type >::head ( size_t  n)
inline
Returns
an ArrayView encapsulating the first n elements

Definition at line 238 of file array_view.hpp.

◆ head() [2/2]

template<class Type>
ArrayView<const value_type> CppAD::cg::ArrayView< Type >::head ( size_t  n) const
inline
Returns
an ArrayView encapsulating the first n elements

Definition at line 246 of file array_view.hpp.

◆ max_size()

template<class Type>
size_type CppAD::cg::ArrayView< Type >::max_size ( ) const
inlinenoexcept
Returns
number of elements in the array.

Definition at line 209 of file array_view.hpp.

◆ segment() [1/2]

template<class Type>
ArrayView<value_type> CppAD::cg::ArrayView< Type >::segment ( size_t  start,
size_t  n 
)
inline
Returns
an ArrayView encapsulating n elements starting at position start

Definition at line 270 of file array_view.hpp.

◆ segment() [2/2]

template<class Type>
ArrayView<const value_type> CppAD::cg::ArrayView< Type >::segment ( size_t  start,
size_t  n 
) const
inline
Returns
an ArrayView encapsulating n elements starting at position start

Definition at line 280 of file array_view.hpp.

◆ size()

template<class Type>
size_t CppAD::cg::ArrayView< Type >::size ( ) const
inlinenoexcept

◆ tail() [1/2]

template<class Type>
ArrayView<value_type> CppAD::cg::ArrayView< Type >::tail ( size_t  n)
inline
Returns
an ArrayView encapsulating the last n elements

Definition at line 254 of file array_view.hpp.

◆ tail() [2/2]

template<class Type>
ArrayView<const value_type> CppAD::cg::ArrayView< Type >::tail ( size_t  n) const
inline
Returns
an ArrayView encapsulating the last n elements

Definition at line 262 of file array_view.hpp.


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