ReFRACtor
FullPhysics::ArrayAd< T, D > Class Template Reference

The AutoDerivative<T> works well, and it works with blitz if you create a blitz::Array<AutoDerivative<T>, D>, however the performance tends to be a bit poor for larger Arrays because of all the temporaries that get created. More...

#include <array_ad.h>

+ Collaboration diagram for FullPhysics::ArrayAd< T, D >:

Public Member Functions

 ArrayAd (const blitz::Array< AutoDerivative< T >, D > &V)
 
 ArrayAd (const ArrayAd< T, D > &V)
 
 ArrayAd (const blitz::Array< T, D > &Val, const blitz::Array< T, D+1 > &Jac, bool Is_const=false, bool Force_copy=false)
 
 ArrayAd (const blitz::Array< T, D > &Val, bool Force_copy=false)
 
 ArrayAd (const blitz::Array< T, D > &Val, int nvar, bool Force_copy=false)
 
 ArrayAd ()
 
 ArrayAd (int n1, int nvar)
 
 ArrayAd (int n1, int n2, int nvar)
 
 ArrayAd (int n1, int n2, int n3, int nvar)
 
 ArrayAd (int n1, int n2, int n3, int n4, int nvar)
 
 ArrayAd (int n1, int n2, int n3, int n4, int n5, int nvar)
 
 ArrayAd (const blitz::TinyVector< int, D > &Shape, int nvar)
 
int cols () const
 
ArrayAd< T, D > copy () const
 
int depth () const
 
bool is_constant () const
 
const blitz::Array< T, D+1 > jacobian () const
 
blitz::Array< T, D+1 > & jacobian ()
 
int number_variable () const
 
bool operator!= (const ArrayAd< T, D > &A) const
 
AutoDerivativeRef< T > operator() (int i1)
 
AutoDerivativeRef< T > operator() (int i1, int i2)
 
AutoDerivativeRef< T > operator() (int i1, int i2, int i3)
 
AutoDerivativeRef< T > operator() (int i1, int i2, int i3, int i4)
 
AutoDerivativeRef< T > operator() (int i1, int i2, int i3, int i4, int i5)
 
AutoDerivative< T > operator() (int i1) const
 
AutoDerivative< T > operator() (int i1, int i2) const
 
AutoDerivative< T > operator() (int i1, int i2, int i3) const
 
AutoDerivative< T > operator() (int i1, int i2, int i3, int i4) const
 
AutoDerivative< T > operator() (int i1, int i2, int i3, int i4, int i5) const
 
ArrayAd< T, 1 > operator() (const blitz::Range &r1) const
 
template<typename T1 , typename T2 >
ArrayAd< T, blitz::SliceInfo< T, T1, T2 >::rank > operator() (T1 r1, T2 r2) const
 
template<typename T1 , typename T2 , typename T3 >
ArrayAd< T, blitz::SliceInfo< T, T1, T2, T3 >::rank > operator() (T1 r1, T2 r2, T3 r3) const
 
template<typename T1 , typename T2 , typename T3 , typename T4 >
ArrayAd< T, blitz::SliceInfo< T, T1, T2, T3, T4 >::rank > operator() (T1 r1, T2 r2, T3 r3, T4 r4) const
 
template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 >
ArrayAd< T, blitz::SliceInfo< T, T1, T2, T3, T4, T5 >::rank > operator() (T1 r1, T2 r2, T3 r3, T4 r4, T5 r5) const
 
ArrayAdoperator= (const ArrayAd< T, D > &V)
 
ArrayAdoperator= (const blitz::Array< T, D > &V)
 
ArrayAdoperator= (const T &V)
 
ArrayAdoperator= (const AutoDerivative< T > &V)
 
bool operator== (const ArrayAd< T, D > &A) const
 We define != in terms of this operator. More...
 
void reference (const ArrayAd< T, D > &V)
 
void resize (const blitz::TinyVector< int, D > &Shape, int nvar)
 
void resize (int n1, int nvar)
 
void resize (int n1, int n2, int nvar)
 
void resize (int n1, int n2, int n3, int nvar)
 
void resize (int n1, int n2, int n3, int n4, int nvar)
 
void resize (int n1, int n2, int n3, int n4, int n5, int nvar)
 
void resize_number_variable (int nvar)
 
int rows () const
 
const blitz::TinyVector< int, D > & shape () const
 
blitz::Array< AutoDerivative< T >, D > to_array () const
 
const blitz::Array< T, D > & value () const
 
blitz::Array< T, D > & value ()
 

Friends

std::ostream & operator<< (std::ostream &os, const ArrayAd< T, D > &V)
 
std::istream & operator>> (std::istream &is, ArrayAd< T, D > &V)
 

Detailed Description

template<class T, int D>
class FullPhysics::ArrayAd< T, D >

The AutoDerivative<T> works well, and it works with blitz if you create a blitz::Array<AutoDerivative<T>, D>, however the performance tends to be a bit poor for larger Arrays because of all the temporaries that get created.

This class keeps all the values together in one blitz::Array, and all the gradients in one Jacobian blitz::Array. This is less flexible than a blitz::Array<AutoDerivative<T>, D>, but the peformance is much better. We can convert to and from AutoDerivative<T> as needed, so this gives us the best of both worlds - ArrayAd when we don't need the extra functionality, convert to AutoDerivative<T> when needed.

A note on the implementation, blitz doesn't handle Range::all() well with a zero size array. So we always ensure that the Jacobian has at least one column, even for constant values with the nvars = 0. We track if this is a constant separately.

We can get odd floating point errors (particularly on Ubuntu), if we copy garbage values. So even though we don't use the Jacobian, if the data is constant, we initialize it to 0.

Definition at line 40 of file array_ad.h.

Constructor & Destructor Documentation

◆ ArrayAd() [1/12]

template<class T, int D>
FullPhysics::ArrayAd< T, D >::ArrayAd ( const blitz::Array< AutoDerivative< T >, D > &  V)
inline

Definition at line 43 of file array_ad.h.

◆ ArrayAd() [2/12]

template<class T, int D>
FullPhysics::ArrayAd< T, D >::ArrayAd ( const ArrayAd< T, D > &  V)
inline

Definition at line 52 of file array_ad.h.

◆ ArrayAd() [3/12]

template<class T, int D>
FullPhysics::ArrayAd< T, D >::ArrayAd ( const blitz::Array< T, D > &  Val,
const blitz::Array< T, D+1 > &  Jac,
bool  Is_const = false,
bool  Force_copy = false 
)
inline

Definition at line 82 of file array_ad.h.

◆ ArrayAd() [4/12]

template<class T, int D>
FullPhysics::ArrayAd< T, D >::ArrayAd ( const blitz::Array< T, D > &  Val,
bool  Force_copy = false 
)
inline

Definition at line 98 of file array_ad.h.

◆ ArrayAd() [5/12]

template<class T, int D>
FullPhysics::ArrayAd< T, D >::ArrayAd ( const blitz::Array< T, D > &  Val,
int  nvar,
bool  Force_copy = false 
)
inline

Definition at line 109 of file array_ad.h.

◆ ArrayAd() [6/12]

template<class T, int D>
FullPhysics::ArrayAd< T, D >::ArrayAd ( )
inline

Definition at line 120 of file array_ad.h.

◆ ArrayAd() [7/12]

template<class T, int D>
FullPhysics::ArrayAd< T, D >::ArrayAd ( int  n1,
int  nvar 
)
inline

Definition at line 121 of file array_ad.h.

◆ ArrayAd() [8/12]

template<class T, int D>
FullPhysics::ArrayAd< T, D >::ArrayAd ( int  n1,
int  n2,
int  nvar 
)
inline

Definition at line 127 of file array_ad.h.

◆ ArrayAd() [9/12]

template<class T, int D>
FullPhysics::ArrayAd< T, D >::ArrayAd ( int  n1,
int  n2,
int  n3,
int  nvar 
)
inline

Definition at line 133 of file array_ad.h.

◆ ArrayAd() [10/12]

template<class T, int D>
FullPhysics::ArrayAd< T, D >::ArrayAd ( int  n1,
int  n2,
int  n3,
int  n4,
int  nvar 
)
inline

Definition at line 140 of file array_ad.h.

◆ ArrayAd() [11/12]

template<class T, int D>
FullPhysics::ArrayAd< T, D >::ArrayAd ( int  n1,
int  n2,
int  n3,
int  n4,
int  n5,
int  nvar 
)
inline

Definition at line 147 of file array_ad.h.

◆ ArrayAd() [12/12]

template<class T, int D>
FullPhysics::ArrayAd< T, D >::ArrayAd ( const blitz::TinyVector< int, D > &  Shape,
int  nvar 
)
inline

Definition at line 154 of file array_ad.h.

Member Function Documentation

◆ cols()

template<class T, int D>
int FullPhysics::ArrayAd< T, D >::cols ( ) const
inline

Definition at line 369 of file array_ad.h.

◆ copy()

template<class T, int D>
ArrayAd<T, D> FullPhysics::ArrayAd< T, D >::copy ( ) const
inline

Definition at line 374 of file array_ad.h.

◆ depth()

template<class T, int D>
int FullPhysics::ArrayAd< T, D >::depth ( ) const
inline

Definition at line 370 of file array_ad.h.

◆ is_constant()

template<class T, int D>
bool FullPhysics::ArrayAd< T, D >::is_constant ( ) const
inline

Definition at line 371 of file array_ad.h.

◆ jacobian() [1/2]

template<class T, int D>
const blitz::Array<T, D+1> FullPhysics::ArrayAd< T, D >::jacobian ( ) const
inline

Definition at line 307 of file array_ad.h.

◆ jacobian() [2/2]

template<class T, int D>
blitz::Array<T, D+1>& FullPhysics::ArrayAd< T, D >::jacobian ( )
inline

Definition at line 314 of file array_ad.h.

◆ number_variable()

template<class T, int D>
int FullPhysics::ArrayAd< T, D >::number_variable ( ) const
inline

Definition at line 376 of file array_ad.h.

◆ operator!=()

template<class T, int D>
bool FullPhysics::ArrayAd< T, D >::operator!= ( const ArrayAd< T, D > &  A) const
inline

Definition at line 402 of file array_ad.h.

◆ operator()() [1/15]

template<class T, int D>
AutoDerivativeRef<T> FullPhysics::ArrayAd< T, D >::operator() ( int  i1)
inline

Definition at line 226 of file array_ad.h.

◆ operator()() [2/15]

template<class T, int D>
AutoDerivativeRef<T> FullPhysics::ArrayAd< T, D >::operator() ( int  i1,
int  i2 
)
inline

Definition at line 234 of file array_ad.h.

◆ operator()() [3/15]

template<class T, int D>
AutoDerivativeRef<T> FullPhysics::ArrayAd< T, D >::operator() ( int  i1,
int  i2,
int  i3 
)
inline

Definition at line 242 of file array_ad.h.

◆ operator()() [4/15]

template<class T, int D>
AutoDerivativeRef<T> FullPhysics::ArrayAd< T, D >::operator() ( int  i1,
int  i2,
int  i3,
int  i4 
)
inline

Definition at line 250 of file array_ad.h.

◆ operator()() [5/15]

template<class T, int D>
AutoDerivativeRef<T> FullPhysics::ArrayAd< T, D >::operator() ( int  i1,
int  i2,
int  i3,
int  i4,
int  i5 
)
inline

Definition at line 258 of file array_ad.h.

◆ operator()() [6/15]

template<class T, int D>
AutoDerivative<T> FullPhysics::ArrayAd< T, D >::operator() ( int  i1) const
inline

Definition at line 266 of file array_ad.h.

◆ operator()() [7/15]

template<class T, int D>
AutoDerivative<T> FullPhysics::ArrayAd< T, D >::operator() ( int  i1,
int  i2 
) const
inline

Definition at line 274 of file array_ad.h.

◆ operator()() [8/15]

template<class T, int D>
AutoDerivative<T> FullPhysics::ArrayAd< T, D >::operator() ( int  i1,
int  i2,
int  i3 
) const
inline

Definition at line 282 of file array_ad.h.

◆ operator()() [9/15]

template<class T, int D>
AutoDerivative<T> FullPhysics::ArrayAd< T, D >::operator() ( int  i1,
int  i2,
int  i3,
int  i4 
) const
inline

Definition at line 290 of file array_ad.h.

◆ operator()() [10/15]

template<class T, int D>
AutoDerivative<T> FullPhysics::ArrayAd< T, D >::operator() ( int  i1,
int  i2,
int  i3,
int  i4,
int  i5 
) const
inline

Definition at line 298 of file array_ad.h.

◆ operator()() [11/15]

template<class T, int D>
ArrayAd<T, 1> FullPhysics::ArrayAd< T, D >::operator() ( const blitz::Range &  r1) const
inline

Definition at line 335 of file array_ad.h.

◆ operator()() [12/15]

template<class T, int D>
template<typename T1 , typename T2 >
ArrayAd<T,blitz::SliceInfo<T,T1,T2>::rank> FullPhysics::ArrayAd< T, D >::operator() ( T1  r1,
T2  r2 
) const
inline

Definition at line 340 of file array_ad.h.

◆ operator()() [13/15]

template<class T, int D>
template<typename T1 , typename T2 , typename T3 >
ArrayAd<T,blitz::SliceInfo<T,T1,T2,T3>::rank> FullPhysics::ArrayAd< T, D >::operator() ( T1  r1,
T2  r2,
T3  r3 
) const
inline

Definition at line 347 of file array_ad.h.

◆ operator()() [14/15]

template<class T, int D>
template<typename T1 , typename T2 , typename T3 , typename T4 >
ArrayAd<T,blitz::SliceInfo<T,T1,T2,T3,T4>::rank> FullPhysics::ArrayAd< T, D >::operator() ( T1  r1,
T2  r2,
T3  r3,
T4  r4 
) const
inline

Definition at line 354 of file array_ad.h.

◆ operator()() [15/15]

template<class T, int D>
template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 >
ArrayAd<T,blitz::SliceInfo<T,T1,T2,T3,T4,T5>::rank> FullPhysics::ArrayAd< T, D >::operator() ( T1  r1,
T2  r2,
T3  r3,
T4  r4,
T5  r5 
) const
inline

Definition at line 362 of file array_ad.h.

◆ operator=() [1/4]

template<class T, int D>
ArrayAd& FullPhysics::ArrayAd< T, D >::operator= ( const ArrayAd< T, D > &  V)
inline

Definition at line 57 of file array_ad.h.

◆ operator=() [2/4]

template<class T, int D>
ArrayAd& FullPhysics::ArrayAd< T, D >::operator= ( const blitz::Array< T, D > &  V)
inline

Definition at line 323 of file array_ad.h.

◆ operator=() [3/4]

template<class T, int D>
ArrayAd& FullPhysics::ArrayAd< T, D >::operator= ( const T &  V)
inline

Definition at line 325 of file array_ad.h.

◆ operator=() [4/4]

template<class T, int D>
ArrayAd& FullPhysics::ArrayAd< T, D >::operator= ( const AutoDerivative< T > &  V)
inline

Definition at line 327 of file array_ad.h.

◆ operator==()

template<class T, int D>
bool FullPhysics::ArrayAd< T, D >::operator== ( const ArrayAd< T, D > &  A) const
inline

We define != in terms of this operator.

Definition at line 392 of file array_ad.h.

◆ reference()

template<class T, int D>
void FullPhysics::ArrayAd< T, D >::reference ( const ArrayAd< T, D > &  V)
inline

Definition at line 372 of file array_ad.h.

◆ resize() [1/6]

template<class T, int D>
void FullPhysics::ArrayAd< T, D >::resize ( const blitz::TinyVector< int, D > &  Shape,
int  nvar 
)
inline

Definition at line 177 of file array_ad.h.

◆ resize() [2/6]

template<class T, int D>
void FullPhysics::ArrayAd< T, D >::resize ( int  n1,
int  nvar 
)
inline

Definition at line 189 of file array_ad.h.

◆ resize() [3/6]

template<class T, int D>
void FullPhysics::ArrayAd< T, D >::resize ( int  n1,
int  n2,
int  nvar 
)
inline

Definition at line 196 of file array_ad.h.

◆ resize() [4/6]

template<class T, int D>
void FullPhysics::ArrayAd< T, D >::resize ( int  n1,
int  n2,
int  n3,
int  nvar 
)
inline

Definition at line 203 of file array_ad.h.

◆ resize() [5/6]

template<class T, int D>
void FullPhysics::ArrayAd< T, D >::resize ( int  n1,
int  n2,
int  n3,
int  n4,
int  nvar 
)
inline

Definition at line 210 of file array_ad.h.

◆ resize() [6/6]

template<class T, int D>
void FullPhysics::ArrayAd< T, D >::resize ( int  n1,
int  n2,
int  n3,
int  n4,
int  n5,
int  nvar 
)
inline

Definition at line 218 of file array_ad.h.

◆ resize_number_variable()

template<class T, int D>
void FullPhysics::ArrayAd< T, D >::resize_number_variable ( int  nvar)
inline

Definition at line 165 of file array_ad.h.

◆ rows()

template<class T, int D>
int FullPhysics::ArrayAd< T, D >::rows ( ) const
inline

Definition at line 368 of file array_ad.h.

◆ shape()

template<class T, int D>
const blitz::TinyVector<int, D>& FullPhysics::ArrayAd< T, D >::shape ( ) const
inline

Definition at line 383 of file array_ad.h.

◆ to_array()

template<class T, int D>
blitz::Array<AutoDerivative<T>, D> FullPhysics::ArrayAd< T, D >::to_array ( ) const
inline

Definition at line 316 of file array_ad.h.

◆ value() [1/2]

template<class T, int D>
const blitz::Array<T, D>& FullPhysics::ArrayAd< T, D >::value ( ) const
inline

Definition at line 306 of file array_ad.h.

◆ value() [2/2]

template<class T, int D>
blitz::Array<T, D>& FullPhysics::ArrayAd< T, D >::value ( )
inline

Definition at line 313 of file array_ad.h.

Friends And Related Function Documentation

◆ operator<<

template<class T, int D>
std::ostream& operator<< ( std::ostream &  os,
const ArrayAd< T, D > &  V 
)
friend

Definition at line 384 of file array_ad.h.

◆ operator>>

template<class T, int D>
std::istream& operator>> ( std::istream &  is,
ArrayAd< T, D > &  V 
)
friend

Definition at line 387 of file array_ad.h.


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

Copyright © 2017, California Institute of Technology.
ALL RIGHTS RESERVED.
U.S. Government Sponsorship acknowledged.
Generated Fri Aug 24 2018 15:44:12