TMB Documentation  v1.9.10
Public Member Functions | Public Attributes | List of all members
TMBad::global::ad_aug Struct Reference

Augmented AD type. More...

#include <global.hpp>

Public Member Functions

 ad_aug ()
 Default CTOR. More...
 
 ad_aug (Scalar x)
 CTOR from scalar. More...
 
 ad_aug (ad_plain x)
 CTOR from ad_plain More...
 
void addToTape () const
 Force this variable to be put on the tape. More...
 
bool bothConstant (const ad_aug &other) const
 If true 'this' and 'other' are both constants. If false nothing can be concluded (they might be constants on the tape)
 
bool constant () const
 Is this object guarantied to be a constant? More...
 
ad_aug copy () const
 Deep copy existing ad_aug. Result will be last value of the current tape.
 
ad_aug copy0 () const
 Deep copy existing ad_aug wihout derivatives.
 
void Dependent ()
 Set this ad_aug as dependent.
 
globalglob () const
 Get the tape of this ad_aug. More...
 
bool identical (const ad_aug &other) const
 If true 'this' and 'other' are identical. If false nothing can be concluded (they might be equal, but different, expressions on the tape)
 
bool identicalOne () const
 If true this variable is identical one. If false nothing can be concluded.
 
bool identicalZero () const
 If true this variable is identical zero. If false nothing can be concluded.
 
bool in_context_stack (global *glob) const
 Check if 'glob' exists in the active context stack.
 
void Independent ()
 Set this ad_aug as independent.
 
bool on_active_tape () const
 Is this object on the current active tape?
 
bool on_some_tape () const
 Is this object on some (not necessarily active) tape?
 
bool ontape () const
 Alias for on_some_tape() (for backward compatibility only)
 
ad_aug operator* (const ad_aug &other) const
 Multiplication. More...
 
ad_augoperator*= (const ad_aug &other)
 Compound assignment taking advantage of operator* reductions.
 
ad_aug operator+ (const ad_aug &other) const
 Addition. More...
 
ad_augoperator+= (const ad_aug &other)
 Compound assignment taking advantage of operator+ reductions.
 
ad_aug operator- (const ad_aug &other) const
 Subtraction. More...
 
ad_aug operator- () const
 Negation.
 
ad_augoperator-= (const ad_aug &other)
 Compound assignment taking advantage of operator- reductions.
 
ad_aug operator/ (const ad_aug &other) const
 Division. More...
 
ad_augoperator/= (const ad_aug &other)
 Compound assignment taking advantage of operator/ reductions.
 
void override_by (const ad_plain &x) const
 Override this ad_plain and set glob to get_glob() More...
 
Scalar Value () const
 Return the underlying scalar value of this ad_aug.
 

Public Attributes

ad_plain taped_value
 If taped_value is initialized (see ad_plain::initialize) this is the value of ad_aug.
 
 TMBAD_UNION_OR_STRUCT
 If taped_value is not initialized then this is the value of ad_aug. Otherwise, value is un-defined, and glob is the tape on which this ad_aug resides.
 

Detailed Description

Augmented AD type.

ad_aug is an 'augmented' AD type which, in contrast to ad_plain, knows on which tape it belongs. This facilitates some extra features:

Nested AD: An ad_aug may refer to other variables on different tapes as long as they can be found in the 'active context stack' (defined here: TMBad::global).

In addition, ad_aug can keep tapes small by only adding operations when strictly necessary. For instance, it detects whether a variable is constant or identical zero to see if a reduction is possible to avoid adding the variable to the tape.

The downside of ad_aug is that is takes up slightly more memory than ad_plain.

Examples:
TMBad/spa_gauss.cpp.

Definition at line 2831 of file global.hpp.

Constructor & Destructor Documentation

§ ad_aug() [1/3]

TMBad::global::ad_aug::ad_aug ( )

Default CTOR.

Leaves taped_value in uninitialized state to signify that this variable is constant.

Definition at line 2195 of file TMBad.cpp.

Referenced by Independent().

§ ad_aug() [2/3]

TMBad::global::ad_aug::ad_aug ( Scalar  x)

CTOR from scalar.

Leaves taped_value in uninitialized state to signify that this variable is constant.

Definition at line 2197 of file TMBad.cpp.

§ ad_aug() [3/3]

TMBad::global::ad_aug::ad_aug ( ad_plain  x)

CTOR from ad_plain

Leaves value uninitialized.

Definition at line 2199 of file TMBad.cpp.

Member Function Documentation

§ addToTape()

void TMBad::global::ad_aug::addToTape ( ) const

Force this variable to be put on the tape.

If variable already is on the tape nothing happens. In particular the variable cannot be assumed to be the most recently added.

Definition at line 2201 of file TMBad.cpp.

Referenced by copy(), copy0(), and Dependent().

§ constant()

bool TMBad::global::ad_aug::constant ( ) const

Is this object guarantied to be a constant?

Note
If false the object may or may not be constant.

Definition at line 2180 of file TMBad.cpp.

Referenced by bothConstant(), identical(), identicalOne(), identicalZero(), Independent(), operator*(), and operator-().

§ glob()

global* TMBad::global::ad_aug::glob ( ) const

Get the tape of this ad_aug.

Returns
Returns the tape address of this variable if variable belongs to some tape. Otherwise NULL is returned.

Referenced by TMBad::accumulation_tree_split(), constant(), and identical().

§ operator*()

ad_aug TMBad::global::ad_aug::operator* ( const ad_aug other) const

Multiplication.

Included reductions:

  • 0 * x = 0
  • x * 0 = 0
  • 1 * x = x
  • x * 1 = x

Definition at line 2290 of file TMBad.cpp.

Referenced by Independent().

§ operator+()

ad_aug TMBad::global::ad_aug::operator+ ( const ad_aug other) const

Addition.

Included reductions:

  • 0 + x = x
  • x + 0 = x

Definition at line 2270 of file TMBad.cpp.

Referenced by Independent().

§ operator-()

ad_aug TMBad::global::ad_aug::operator- ( const ad_aug other) const

Subtraction.

Included reductions:

  • x - 0 = x
  • 0 - x = -x
  • x - x = 0

Definition at line 2277 of file TMBad.cpp.

§ operator/()

ad_aug TMBad::global::ad_aug::operator/ ( const ad_aug other) const

Division.

Included reductions:

  • 0 / x = 0
  • x / 1 = x

Definition at line 2301 of file TMBad.cpp.

Referenced by Independent().

§ override_by()

void TMBad::global::ad_aug::override_by ( const ad_plain &  x) const

Override this ad_plain and set glob to get_glob()

Warning
Internal use only

Definition at line 2218 of file TMBad.cpp.


The documentation for this struct was generated from the following files:
License: GPL v2