Theoretica
A C++ numerical and automatic mathematical library
theoretica::multidual< N > Class Template Reference

Multidual number algebra for functions of the form \(f: \mathbb{R}^n \rightarrow \mathbb{R}\). More...

#include <multidual.h>

Public Member Functions

 multidual ()
 Construct a multidual number as \((0 + \vec 0)\).
 
 multidual (real r, vec< real, N > u)
 Construct a multidual number from a real number and an N dimensional vector.
 
 multidual (real r)
 Construct a multidual number from a real number.
 
multidualoperator= (real x)
 Initialize a multidual number from a real number.
 
real Re () const
 Get the real part.
 
realRe ()
 Access the real part.
 
vec< real, N > Dual () const
 Get the multidual part.
 
vec< real, N > & Dual ()
 Access the multidual part.
 
multidual conjugate () const
 Get the multidual conjugate.
 
multidual inverse () const
 Get the inverse of a multidual number.
 
multidual operator+ () const
 Identity (for consistency)
 
multidual operator+ (const multidual &other) const
 Sum two multidual numbers.
 
multidual operator+ (real r) const
 Sum a real number to a multidual number.
 
multidual operator- () const
 Get the opposite of a multidual number.
 
multidual operator- (const multidual &other) const
 Subtract two multidual numbers.
 
multidual operator- (real r) const
 Subtract a real number from a multidual number.
 
multidual operator* (const multidual &other) const
 Multiply two multidual numbers.
 
multidual operator* (real r) const
 Multiply a multidual number by a real number.
 
multidual operator/ (const multidual &other) const
 Dual division.
 
multidual operator/ (real r) const
 Divide a multidual number by a real number.
 
multidualoperator+= (const multidual &other)
 Sum a real number to this one.
 
multidualoperator+= (real r)
 Sum a real number to this multidual number.
 
multidualoperator-= (const multidual &other)
 Subtract a real number from this one.
 
multidualoperator-= (real r)
 Subtract a real number from this multidual number.
 
multidualoperator*= (const multidual &other)
 Multiply this multidual number by another one.
 
multidualoperator*= (real r)
 Multiply this multidual number by a real number.
 
multidualoperator/= (const multidual &other)
 Divide this multidual number by another one.
 
multidualoperator/= (real r)
 Divide a multidual number by a real number.
 
bool operator== (const multidual &other)
 Check whether two multidual numbers have the same real and multidual parts.
 
unsigned int size () const
 Get the number of independent variables associated with the multidual number.
 
void resize (unsigned int size)
 Change the size of the dual part of the number (only for dynamically allocated vectors)
 
std::string to_string (const std::string &epsilon="e") const
 Convert the multidual number to string representation. More...
 
 operator std::string ()
 Convert the multidual number to string representation.
 

Static Public Member Functions

static vec< multidual< N >, N > make_argument (const vec< real, N > &x)
 Construct an N-dimensional vector of multidual numbers to be passed as argument to a multidual function. More...
 
static vec< real, N > extract_real (const vec< multidual< N >, N > &v)
 Extract the real vector from a vector of multidual numbers as a vec<real, N>
 
static mat< real, N, N > extract_dual (const vec< multidual< N >, N > &v)
 Extract the dual matrix (Jacobian) from a vector of multidual numbers as a mat<N, N>
 
static void extract (const vec< multidual< N >, N > &v, vec< real, N > &x, mat< real, N, N > &J)
 Extract the real vector and dual matrix from a vector of multidual numbers as a vec<real, N> and mat<real, N, N>
 

Public Attributes

real a
 The real part of the multidimensional dual number.
 
vec< real, N > v
 The dual part of the multidimensional dual number as a real vector.
 

Static Public Attributes

static constexpr size_t vector_argument = N
 

Friends

multidual operator+ (real a, const multidual &d)
 
multidual operator- (real a, const multidual &d)
 
multidual operator* (real a, const multidual &d)
 
multidual operator/ (real a, const multidual &d)
 
std::ostream & operator<< (std::ostream &out, const multidual &obj)
 Stream the multidual number in string representation to an output stream (std::ostream)
 

Detailed Description

template<unsigned int N = 0>
class theoretica::multidual< N >

Multidual number algebra for functions of the form \(f: \mathbb{R}^n \rightarrow \mathbb{R}\).

Member Function Documentation

◆ make_argument()

template<unsigned int N = 0>
static vec<multidual<N>, N> theoretica::multidual< N >::make_argument ( const vec< real, N > &  x)
inlinestatic

Construct an N-dimensional vector of multidual numbers to be passed as argument to a multidual function.

Parameters
xA vector of real numbers containing the variables to pass

◆ to_string()

template<unsigned int N = 0>
std::string theoretica::multidual< N >::to_string ( const std::string &  epsilon = "e") const
inline

Convert the multidual number to string representation.

Parameters
epsilonThe character to use to represent epsilon

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