ADOL-C: Automatic Differentiation in C/C++ 2.7.3
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
adouble Class Reference

Taped active scalar for reusable forward and reverse differentiation. More...

#include <adtb_types.h>

Public Member Functions

 ~adouble ()=default
 Default destructor.
 
 adouble ()
 Allocate an active-value location on the current tape.
 
 adouble (double coval)
 Allocate a location on the current tape and initialize its value.
 
 adouble (const adouble &a)
 Copy constructor.
 
 adouble (adouble &&other) noexcept
 Move constructor.
 
size_t release_loc ()
 Releases ownership of this adouble's location.
 
bool is_valid () const
 
adouble & operator= (const double coval)
 Assign a passive value and record the assignment while tracing.
 
adouble & operator= (const adouble &a)
 Copy an active value and record the assignment while tracing.
 
adouble & operator= (adouble &&other) noexcept
 Move assignment.
 
adouble & operator= (const pdouble &p)
 Registers the assignment of the pdouble to the adouble.
 
double value () const
 Retrieves the current value stored at the tape location.
 
size_t loc () const
 Retrieves the location of the adouble on the tape.
 
void value (const double coval)
 Updates the value stored at the tape location.
 
 operator double () const
 Converts the adouble to a double by returning its corresponding double value from the tape.
 
adouble & operator+= (const double coval)
 
adouble & operator+= (const adouble &a)
 
adouble & operator+= (adouble &&a)
 
adouble & operator+= (const pdouble &p)
 
adouble & operator-= (const double coval)
 
adouble & operator-= (const adouble &a)
 
adouble & operator-= (adouble &&a)
 
adouble & operator-= (const pdouble &p)
 
adouble & operator*= (const double coval)
 
adouble & operator*= (const adouble &a)
 
adouble & operator*= (const pdouble &p)
 
adouble & operator/= (const double coval)
 
adouble & operator/= (const adouble &a)
 
adouble & operator/= (adouble &&a)
 
adouble & operator/= (const pdouble &p)
 
adouble operator++ (int)
 
adouble operator-- (int)
 
adouble & operator++ ()
 
adouble & operator-- ()
 
adouble & operator<<= (const double input)
 Registers the assignment of the input value to the adouble and marks the adouble as an independent variable.
 
adouble & operator>>= (double &out)
 Stores the value of adouble in the provided reference and marks the adouble as a dependent variable.
 
void declareIndependent ()
 Declares the adouble as an independent variable on the tape.
 
void declareDependent ()
 Declares the adouble as a dependent variable on the tape.
 

Static Public Member Functions

static adouble borrow_location (size_t loc)
 Constructs an adouble borrowing an existing tape location.
 

Detailed Description

Taped active scalar for reusable forward and reverse differentiation.

Each adouble owns or borrows a location in the current ValueTape. Double-like overloads compute the primal result immediately and, while tracing, append the operation and its operand/result locations to the tape. The recorded function can later be evaluated by first- or higher-order forward and reverse sweeps.

Constructor & Destructor Documentation

◆ ~adouble()

adouble::~adouble ( )
default

Default destructor.

◆ adouble() [1/4]

adouble::adouble ( )

Allocate an active-value location on the current tape.

If ADOLC_ADOUBLE_STDCZERO is defined, initialize its value to zero. Otherwise, assign a value before reading it.

◆ adouble() [2/4]

adouble::adouble ( double  coval)

Allocate a location on the current tape and initialize its value.

Parameters
covalValue that is stored on the tape at the new location.

◆ adouble() [3/4]

adouble::adouble ( const adouble &  a)

Copy constructor.

Allocate a location on the current tape and copy the source value. Record the assignment while tracing. The source must belong to this tape.

Parameters
aThe adouble to copy.

◆ adouble() [4/4]

adouble::adouble ( adouble &&  other)
inlinenoexcept

Move constructor.

Transfers the location from the input adouble.

Parameters
otherThe adouble to transfer.

Member Function Documentation

◆ borrow_location()

static adouble adouble::borrow_location ( size_t  loc)
inlinestatic

Constructs an adouble borrowing an existing tape location.

The resulting adouble does not own the location and therefore does not free it on destruction.

◆ declareDependent()

void adouble::declareDependent ( )

Declares the adouble as a dependent variable on the tape.

◆ declareIndependent()

void adouble::declareIndependent ( )

Declares the adouble as an independent variable on the tape.

◆ is_valid()

bool adouble::is_valid ( ) const
inline

◆ loc()

size_t adouble::loc ( ) const
inline

Retrieves the location of the adouble on the tape.

Returns
The location on the tape.

◆ operator double()

adouble::operator double ( ) const
inlineexplicit

Converts the adouble to a double by returning its corresponding double value from the tape.

Returns
The value of the adouble at the tape location.

◆ operator*=() [1/3]

adouble & adouble::operator*= ( const adouble &  a)

◆ operator*=() [2/3]

adouble & adouble::operator*= ( const double  coval)

◆ operator*=() [3/3]

ADOLC_API adouble & adouble::operator*= ( const pdouble &  p)
inline

◆ operator++() [1/2]

adouble & adouble::operator++ ( )

◆ operator++() [2/2]

adouble adouble::operator++ ( int  )

◆ operator+=() [1/4]

adouble & adouble::operator+= ( adouble &&  a)

◆ operator+=() [2/4]

adouble & adouble::operator+= ( const adouble &  a)

◆ operator+=() [3/4]

adouble & adouble::operator+= ( const double  coval)

◆ operator+=() [4/4]

ADOLC_API adouble & adouble::operator+= ( const pdouble &  p)
inline

PDOUBLE ARTIHEMTICS

◆ operator--() [1/2]

adouble & adouble::operator-- ( )

◆ operator--() [2/2]

adouble adouble::operator-- ( int  )

◆ operator-=() [1/4]

adouble & adouble::operator-= ( adouble &&  a)

◆ operator-=() [2/4]

adouble & adouble::operator-= ( const adouble &  a)

◆ operator-=() [3/4]

adouble & adouble::operator-= ( const double  coval)

◆ operator-=() [4/4]

ADOLC_API adouble & adouble::operator-= ( const pdouble &  p)
inline

◆ operator/=() [1/4]

ADOLC_API adouble & adouble::operator/= ( adouble &&  a)
inline

◆ operator/=() [2/4]

ADOLC_API adouble & adouble::operator/= ( const adouble &  a)
inline

◆ operator/=() [3/4]

ADOLC_API adouble & adouble::operator/= ( const double  coval)
inline

◆ operator/=() [4/4]

ADOLC_API adouble & adouble::operator/= ( const pdouble &  p)
inline

◆ operator<<=()

adouble & adouble::operator<<= ( const double  input)

Registers the assignment of the input value to the adouble and marks the adouble as an independent variable.

Use the span overload below to register several contiguous independent variables in one call while preserving their order on the tape.

Parameters
inputValue that is assigned to the adouble.
Returns
A reference to the adouble.

◆ operator=() [1/4]

adouble & adouble::operator= ( adouble &&  other)
inlinenoexcept

Move assignment.

Transfers the location from the input adouble.

Parameters
otherThe adouble to transfer.
Returns
Reference to *this.

◆ operator=() [2/4]

adouble & adouble::operator= ( const adouble &  a)

Copy an active value and record the assignment while tracing.

Parameters
aThe adouble to assign.
Returns
Reference to *this.

◆ operator=() [3/4]

adouble & adouble::operator= ( const double  coval)

Assign a passive value and record the assignment while tracing.

Parameters
covalThe value to assign.
Returns
Reference to *this.

◆ operator=() [4/4]

adouble & adouble::operator= ( const pdouble &  p)

Registers the assignment of the pdouble to the adouble.

Parameters
pThe pdouble to assign.
Returns
Reference to *this.

◆ operator>>=()

adouble & adouble::operator>>= ( double &  out)

Stores the value of adouble in the provided reference and marks the adouble as a dependent variable.

Use the span overload below to register several contiguous dependent variables in one call while preserving their order on the tape.

Parameters
outReceives the dependent value.
Returns
A reference to the adouble.

◆ release_loc()

size_t adouble::release_loc ( )
inline

Releases ownership of this adouble's location.

The returned location can be re-wrapped via borrow_location(). The source adouble is invalid after this call.

◆ value() [1/2]

double adouble::value ( ) const
inline

Retrieves the current value stored at the tape location.

Returns
The value of the adouble from the tape.

Central validity guard: operator implementations call value()/loc(), so we keep validity assertions here instead of duplicating checks per operator.

◆ value() [2/2]

void adouble::value ( const double  coval)
inline

Updates the value stored at the tape location.

Parameters
covalthe new value to assign.

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