Theoretica
A C++ numerical and automatic mathematical library
theoretica::dual Class Reference

Dual number class. More...

#include <dual.h>

Public Member Functions

 dual ()
 Default constructor, initialize with null values.
 
 dual (real real_part, real dual_part)
 Initialize from two real numbers.
 
 dual (real real_part)
 Initialize from a real number.
 
 dual (const vec2 &v)
 Initialize from a vec2.
 
dualoperator= (const vec2 &v)
 Initialize a dual number from a vec2.
 
dualoperator= (real x)
 Initialize a dual number from a real number.
 
dualoperator= (const std::array< real, 2 > &v)
 Initialize a dual number from a std::array.
 
const realRe () const
 Return real part.
 
realRe ()
 Return real part.
 
const realDual () const
 Return dual part.
 
realDual ()
 Return dual part.
 
dual conjugate () const
 Get the dual conjugate.
 
dual inverse () const
 Get the inverse of a dual number.
 
dual operator+ () const
 Identity (for consistency)
 
dual operator+ (const dual &other) const
 Sum two dual numbers.
 
dual operator+ (real r) const
 Sum a real number to a dual number.
 
dual operator- () const
 Get the opposite of a dual number.
 
dual operator- (const dual &other) const
 Subtract two dual numbers.
 
dual operator- (real r) const
 Subtract a real number from a dual number.
 
dual operator* (const dual &other) const
 Multiply two dual numbers.
 
dual operator* (real r) const
 Multiply a dual number by a real number.
 
dual operator/ (const dual &other) const
 Dual division.
 
dual operator/ (real r) const
 Divide a dual number by a real number.
 
dualoperator+= (real r)
 Sum a real number to this dual number.
 
dualoperator-= (const dual &other)
 Subtract a real number from this one.
 
dualoperator-= (real r)
 Subtract a real number from this dual number.
 
dualoperator*= (const dual &other)
 Multiply this dual number by another one.
 
dualoperator*= (real r)
 Multiply this dual number by a real number.
 
dualoperator/= (const dual &other)
 Divide this dual number by another one.
 
dualoperator/= (real r)
 Divide a dual number by a real number.
 
bool operator== (const dual &other)
 Check whether two dual numbers have the same real and dual parts.
 
vec2 to_vec () const
 Convert a dual number to a vector.
 
void from_vec (const vec2 &v)
 Initialize from a vector.
 
mat2 to_mat () const
 Convert a dual number to matrix form.
 
std::string to_string (const std::string &epsilon="e") const
 Convert the dual number to string representation. More...
 
 operator std::string ()
 Convert the dual number to string representation.
 

Public Attributes

real a
 
real b
 

Friends

real Re (const dual &d)
 Extract the real part of the dual number.
 
realRe (dual &d)
 Extract the real part of the dual number.
 
real Dual (const dual &d)
 Extract the real part of the dual number.
 
realDual (dual &d)
 Extract the real part of the dual number.
 
dual operator+ (real a, const dual &d)
 
dual operator- (real a, const dual &d)
 
dual operator* (real a, const dual &d)
 
dual operator/ (real a, const dual &d)
 
std::ostream & operator<< (std::ostream &out, const dual &obj)
 Stream the dual number in string representation to an output stream (std::ostream)
 

Detailed Description

Dual number class.

Implemented as \(a + b \epsilon\) where \(\epsilon\) is such that \(\epsilon^2 = 0\)

Member Function Documentation

◆ to_string()

std::string theoretica::dual::to_string ( const std::string &  epsilon = "e") const
inline

Convert the dual number to string representation.

Parameters
epsilonThe character to use to represent epsilon

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