CppADCodeGen 2.4.3
A C++ Algorithmic Differentiation Package with Source Code Generation
Loading...
Searching...
No Matches
CppAD::cg::ArrayView< Type > Class Template Reference

#include <array_view.hpp>

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.

Member Typedef Documentation

◆ const_iterator

template<class Type >
using CppAD::cg::ArrayView< Type >::const_iterator = const value_type*

Definition at line 38 of file array_view.hpp.

◆ const_pointer

template<class Type >
using CppAD::cg::ArrayView< Type >::const_pointer = const value_type*

Definition at line 34 of file array_view.hpp.

◆ const_reference

template<class Type >
using CppAD::cg::ArrayView< Type >::const_reference = const Type&

Definition at line 36 of file array_view.hpp.

◆ const_reverse_iterator

template<class Type >
using CppAD::cg::ArrayView< Type >::const_reverse_iterator = std::reverse_iterator<const_iterator>

Definition at line 39 of file array_view.hpp.

◆ difference_type

template<class Type >
using CppAD::cg::ArrayView< Type >::difference_type = ptrdiff_t

Definition at line 42 of file array_view.hpp.

◆ iterator

template<class Type >
using CppAD::cg::ArrayView< Type >::iterator = value_type*

Definition at line 37 of file array_view.hpp.

◆ pointer

template<class Type >
using CppAD::cg::ArrayView< Type >::pointer = value_type*

Definition at line 33 of file array_view.hpp.

◆ reference

template<class Type >
using CppAD::cg::ArrayView< Type >::reference = value_type&

Definition at line 35 of file array_view.hpp.

◆ reverse_iterator

template<class Type >
using CppAD::cg::ArrayView< Type >::reverse_iterator = std::reverse_iterator<iterator>

Definition at line 40 of file array_view.hpp.

◆ size_type

template<class Type >
using CppAD::cg::ArrayView< Type >::size_type = size_t

Definition at line 41 of file array_view.hpp.

◆ value_type

template<class Type >
using CppAD::cg::ArrayView< Type >::value_type = Type

Definition at line 32 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.

◆ 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

Desctructor

Member Function Documentation

◆ at() [1/2]

template<class Type >
reference CppAD::cg::ArrayView< Type >::at ( size_type i)
inline

Definition at line 352 of file array_view.hpp.

◆ at() [2/2]

template<class Type >
const_reference CppAD::cg::ArrayView< Type >::at ( size_type i) const
inline

Definition at line 358 of file array_view.hpp.

◆ back() [1/2]

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

Definition at line 374 of file array_view.hpp.

◆ back() [2/2]

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

Definition at line 379 of file array_view.hpp.

◆ begin() [1/2]

template<class Type >
const_iterator CppAD::cg::ArrayView< Type >::begin ( ) const
inlinenoexcept

Definition at line 297 of file array_view.hpp.

◆ begin() [2/2]

template<class Type >
iterator CppAD::cg::ArrayView< Type >::begin ( )
inlinenoexcept

Definition at line 293 of file array_view.hpp.

◆ cbegin()

template<class Type >
const_iterator CppAD::cg::ArrayView< Type >::cbegin ( ) const
inlinenoexcept

Definition at line 325 of file array_view.hpp.

◆ cend()

template<class Type >
const_iterator CppAD::cg::ArrayView< Type >::cend ( ) const
inlinenoexcept

Definition at line 329 of file array_view.hpp.

◆ crbegin()

template<class Type >
const_reverse_iterator CppAD::cg::ArrayView< Type >::crbegin ( ) const
inlinenoexcept

Definition at line 333 of file array_view.hpp.

◆ crend()

template<class Type >
const_reverse_iterator CppAD::cg::ArrayView< Type >::crend ( ) const
inlinenoexcept

Definition at line 337 of file array_view.hpp.

◆ data() [1/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.

◆ data() [2/2]

◆ empty()

template<class Type >
bool CppAD::cg::ArrayView< Type >::empty ( ) const
inlinenoexcept

Definition at line 213 of file array_view.hpp.

◆ end() [1/2]

template<class Type >
const_iterator CppAD::cg::ArrayView< Type >::end ( ) const
inlinenoexcept

Definition at line 305 of file array_view.hpp.

◆ end() [2/2]

template<class Type >
iterator CppAD::cg::ArrayView< Type >::end ( )
inlinenoexcept

Definition at line 301 of file array_view.hpp.

◆ fill()

template<class Type >
void CppAD::cg::ArrayView< Type >::fill ( const value_type & u)
inline

Definition at line 231 of file array_view.hpp.

◆ front() [1/2]

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

Definition at line 364 of file array_view.hpp.

◆ front() [2/2]

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

Definition at line 369 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.

◆ operator=() [1/4]

Definition at line 385 of file array_view.hpp.

◆ operator=() [2/4]

template<class Type >
template<typename TT = const Type, typename = typename std::enable_if<!std::is_same<Type, TT>::value && std::is_assignable<Type&, TT&>::value>::type>
ArrayView & CppAD::cg::ArrayView< Type >::operator= ( const ArrayView< TT > & x)
inline

Definition at line 402 of file array_view.hpp.

◆ operator=() [3/4]

Definition at line 427 of file array_view.hpp.

◆ operator=() [4/4]

template<class Type >
ArrayView & CppAD::cg::ArrayView< Type >::operator= ( const std::vector< Type > & x)
inline

Definition at line 415 of file array_view.hpp.

◆ operator[]() [1/2]

template<class Type >
reference CppAD::cg::ArrayView< Type >::operator[] ( size_type i)
inline

Definition at line 342 of file array_view.hpp.

◆ operator[]() [2/2]

template<class Type >
const_reference CppAD::cg::ArrayView< Type >::operator[] ( size_type i) const
inline

Definition at line 347 of file array_view.hpp.

◆ rbegin() [1/2]

template<class Type >
const_reverse_iterator CppAD::cg::ArrayView< Type >::rbegin ( ) const
inlinenoexcept

Definition at line 313 of file array_view.hpp.

◆ rbegin() [2/2]

template<class Type >
reverse_iterator CppAD::cg::ArrayView< Type >::rbegin ( )
inlinenoexcept

Definition at line 309 of file array_view.hpp.

◆ rend() [1/2]

template<class Type >
const_reverse_iterator CppAD::cg::ArrayView< Type >::rend ( ) const
inlinenoexcept

Definition at line 321 of file array_view.hpp.

◆ rend() [2/2]

template<class Type >
reverse_iterator CppAD::cg::ArrayView< Type >::rend ( )
inlinenoexcept

Definition at line 317 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()

◆ swap()

template<class Type >
void CppAD::cg::ArrayView< Type >::swap ( ArrayView< Type > & other)
inlinenoexcept

Definition at line 287 of file array_view.hpp.

◆ 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: