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

Second order dual number class. More...

#include <dual2.h>

Public Member Functions

 dual2 ()
 Default constructor, initialize with null values.
 
 dual2 (real real_part, real dual1_part, real dual2_part)
 Initialize from two real numbers.
 
 dual2 (real real_part, real dual1_part)
 Initialize from two real numbers.
 
 dual2 (real real_part)
 Initialize from a real number.
 
 dual2 (const vec3 &v)
 Initialize from a vec3.
 
dual2operator= (const vec3 &v)
 Initialize a dual number from a vec3.
 
dual2operator= (real x)
 Initialize a dual number from a real number.
 
dual2operator= (const std::array< real, 3 > &v)
 Initialize a dual number from a std::array.
 
real Re () const
 Return real part.
 
real Dual1 () const
 Return first order dual part.
 
real Dual2 () const
 Return second order dual part.
 
dual2 conjugate () const
 Get the dual conjugate.
 
dual2 inverse () const
 Get the inverse of a dual number.
 
dual2 operator+ () const
 Identity (for consistency)
 
dual2 operator+ (const dual2 &other) const
 Sum two dual numbers.
 
dual2 operator+ (real r) const
 Sum a real number to a dual number.
 
dual2 operator- () const
 Get the opposite of a dual number.
 
dual2 operator- (const dual2 &other) const
 Subtract two dual numbers.
 
dual2 operator- (real r) const
 Subtract a real number from a dual number.
 
dual2 operator* (const dual2 &other) const
 Multiply two dual numbers.
 
dual2 operator* (real r) const
 Multiply a dual number by a real number.
 
dual2 operator/ (const dual2 &other) const
 Dual division.
 
dual2 operator/ (real r) const
 Divide a dual number by a real number.
 
dual2operator+= (real r)
 Sum a real number to this dual number.
 
dual2operator-= (const dual2 &other)
 Subtract a real number from this one.
 
dual2operator-= (real r)
 Subtract a real number from this dual number.
 
dual2operator*= (const dual2 &other)
 Multiply this dual number by another one.
 
dual2operator*= (real r)
 Multiply this dual number by a real number.
 
dual2operator/= (const dual2 &other)
 Divide this dual number by another one.
 
dual2operator/= (real r)
 Divide a dual number by a real number.
 
bool operator== (const dual2 &other)
 Check whether two dual numbers have the same real and dual parts.
 
vec3 to_vec () const
 Convert a dual number to a vector.
 
void from_vec (const vec3 &v)
 Initialize from a vector.
 
std::string to_string (const std::string &epsilon1="e1", const std::string &epsilon2="e2") 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
 
real c
 

Friends

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

Detailed Description

Second order dual number class.

Implemented as \(a + b * \epsilon_1 + c * \epsilon_2\) where epsilon is such that \(\epsilon_1^3 = 0\) and \(\epsilon_1 * \epsilon_2 = 0\)

Member Function Documentation

◆ to_string()

std::string theoretica::dual2::to_string ( const std::string &  epsilon1 = "e1",
const std::string &  epsilon2 = "e2" 
) const
inline

Convert the dual number to string representation.

Parameters
epsilon1The character to use to represent epsilon1
epsilon2The character to use to represent epsilon2

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