Sacado  Development
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Classes | Public Types | Public Member Functions | Static Public Attributes | Protected Attributes | Friends | List of all members
Sacado::Fad::Exp::ViewStorage< T, static_length, static_stride, U > Class Template Reference

Derivative array storage class that is a view into a contiguous memory allocation. It does not provide proper value semantics and thus should not be used in a general-purpose scalar type. More...

#include <Sacado_Fad_Exp_ViewStorage.hpp>

Collaboration diagram for Sacado::Fad::Exp::ViewStorage< T, static_length, static_stride, U >:
Collaboration graph
[legend]

Classes

struct  apply
 Turn ViewStorage into a meta-function class usable with mpl::apply. More...
 
struct  apply_N
 Replace static derivative length. More...
 

Public Types

typedef std::remove_cv< T >::type value_type
 
typedef U base_fad_type
 

Public Member Functions

SACADO_INLINE_FUNCTION ViewStorage ()
 Default constructor (needed to satisfy interface)
 
SACADO_INLINE_FUNCTION ViewStorage (T *v, const int arg_size=0, const int arg_stride=0)
 Constructor.
 
SACADO_INLINE_FUNCTION ViewStorage (T *arg_dx, T *arg_val, const int arg_size=0, const int arg_stride=0)
 Constructor.
 
template<typename TT >
SACADO_INLINE_FUNCTION ViewStorage (const ViewStorage< TT, static_length, static_stride, U > &x, typename std::enable_if< std::is_same< TT, T >::value||std::is_same< const TT, T >::value >::type *=0)
 Copy constructor. More...
 
SACADO_INLINE_FUNCTION ~ViewStorage ()
 Destructor.
 
SACADO_INLINE_FUNCTION
ViewStorage
operator= (const ViewStorage &x)
 Assignment.
 
SACADO_INLINE_FUNCTION
constexpr int 
size () const
 Returns number of derivative components.
 
SACADO_INLINE_FUNCTION
constexpr int 
length () const
 Returns array length.
 
SACADO_INLINE_FUNCTION void resize (int sz)
 Resize the derivative array to sz. More...
 
SACADO_INLINE_FUNCTION void resizeAndZero (int sz)
 Resize the derivative array to sz. More...
 
SACADO_INLINE_FUNCTION void expand (int sz)
 Expand derivative array to size sz.
 
SACADO_INLINE_FUNCTION void zero ()
 Zero out derivative array.
 
SACADO_INLINE_FUNCTION const T & val () const
 Returns value.
 
SACADO_INLINE_FUNCTION T & val ()
 Returns value.
 
SACADO_INLINE_FUNCTION const T * dx () const
 Returns derivative array.
 
SACADO_INLINE_FUNCTION T dx (int i) const
 Returns derivative component i with bounds checking.
 
SACADO_INLINE_FUNCTION T & fastAccessDx (int i)
 Returns derivative component i without bounds checking.
 
SACADO_INLINE_FUNCTION const T & fastAccessDx (int i) const
 Returns derivative component i without bounds checking.
 
SACADO_INLINE_FUNCTION
ViewFadPtr< T, static_length,
static_stride, U > 
operator& () const
 Overload of addressof operator.
 

Static Public Attributes

static constexpr bool is_statically_sized = (static_length > 0)
 
static constexpr int static_size = static_length
 
static constexpr bool is_view = true
 

Protected Attributes

const
mpl::integral_nonzero_constant
< int, static_length > 
sz_
 Derivative array size.
 
const
mpl::integral_nonzero_constant
< int, static_stride > 
stride_
 Derivative array stride.
 
T * val_
 Value.
 
T * dx_
 Derivative array.
 

Friends

template<typename , unsigned , unsigned , typename >
class ViewStorage
 

Detailed Description

template<typename T, unsigned static_length, unsigned static_stride, typename U>
class Sacado::Fad::Exp::ViewStorage< T, static_length, static_stride, U >

Derivative array storage class that is a view into a contiguous memory allocation. It does not provide proper value semantics and thus should not be used in a general-purpose scalar type.

Constructor & Destructor Documentation

template<typename T, unsigned static_length, unsigned static_stride, typename U>
template<typename TT >
SACADO_INLINE_FUNCTION Sacado::Fad::Exp::ViewStorage< T, static_length, static_stride, U >::ViewStorage ( const ViewStorage< TT, static_length, static_stride, U > &  x,
typename std::enable_if< std::is_same< TT, T >::value||std::is_same< const TT, T >::value >::type *  = 0 
)
inline

Copy constructor.

Allow, e.g., ViewStorage<double,...>(ViewStorage<double,...>), ViewStorage<const double,...>(ViewStorage<double,...>), and ViewStorage<const double,...>(ViewStorage<const double,...>) but not ViewStorage<double,...>(ViewStorage<const double,...>).

Member Function Documentation

template<typename T, unsigned static_length, unsigned static_stride, typename U>
SACADO_INLINE_FUNCTION void Sacado::Fad::Exp::ViewStorage< T, static_length, static_stride, U >::resize ( int  sz)
inline

Resize the derivative array to sz.

Since we can't actually resize, we check for resizes to zero, which signify assigning a constant. Thus we zero out the derivative components.

References Sacado::Fad::Exp::ViewStorage< T, static_length, static_stride, U >::dx_, Sacado::Fad::Exp::ViewStorage< T, static_length, static_stride, U >::stride_, Sacado::ds_array< T, isScalar >::strided_zero(), and Sacado::Fad::Exp::ViewStorage< T, static_length, static_stride, U >::sz_.

template<typename T, unsigned static_length, unsigned static_stride, typename U>
SACADO_INLINE_FUNCTION void Sacado::Fad::Exp::ViewStorage< T, static_length, static_stride, U >::resizeAndZero ( int  sz)
inline

Resize the derivative array to sz.

We don't do anything here as this is used in the context of resizing the derivative array to zero and then back to some size > 0. Instead we zero out components when it is resized to zero above.


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