OGS
NumLib::Time Struct Reference

Detailed Description

Definition at line 32 of file Time.h.

#include <Time.h>

Collaboration diagram for NumLib::Time:
[legend]

Public Member Functions

constexpr Time (double const time)
 
constexpr double operator() () const
 
constexpr Timeoperator+= (double const increment)
 
constexpr Time operator+ (double const increment) const
 
constexpr Timeoperator-= (double const decrement)
 
constexpr Time operator- (double const decrement) const
 
constexpr std::weak_ordering operator<=> (Time const &b) const
 
constexpr bool operator== (Time const &x) const
 

Private Attributes

MathLib::KahanSum value_
 

Friends

std::ostream & operator<< (std::ostream &os, Time const &t)
 

Constructor & Destructor Documentation

◆ Time()

NumLib::Time::Time ( double const time)
inlineexplicitconstexpr

Definition at line 34 of file Time.h.

34: value_{time} {}
MathLib::KahanSum value_
Definition Time.h:101

Member Function Documentation

◆ operator()()

double NumLib::Time::operator() ( ) const
inlineconstexpr

Definition at line 36 of file Time.h.

36{ return value_(); }

References value_.

◆ operator+()

Time NumLib::Time::operator+ ( double const increment) const
inlineconstexpr

Definition at line 44 of file Time.h.

45 {
46 Time result = *this;
47 result += increment;
48 return result;
49 }
constexpr Time(double const time)
Definition Time.h:34

◆ operator+=()

Time & NumLib::Time::operator+= ( double const increment)
inlineconstexpr

Definition at line 38 of file Time.h.

39 {
40 value_ += increment;
41 return *this;
42 }

References value_.

◆ operator-()

Time NumLib::Time::operator- ( double const decrement) const
inlineconstexpr

Definition at line 57 of file Time.h.

58 {
59 Time result = *this;
60 result -= decrement;
61 return result;
62 }

◆ operator-=()

Time & NumLib::Time::operator-= ( double const decrement)
inlineconstexpr

Definition at line 51 of file Time.h.

52 {
53 value_ -= decrement;
54 return *this;
55 }

References value_.

◆ operator<=>()

std::weak_ordering NumLib::Time::operator<=> ( Time const & b) const
inlineconstexpr

Definition at line 64 of file Time.h.

65 {
66 Time const& a = *this;
67 double const diff = b() - a();
68
69 double const eps = 10 * std::numeric_limits<double>::epsilon() *
70 std::max(1., (std::abs(a()) + std::abs(b())) / 2);
71
72 // Keep for debugging
73 // DBUG("Compare {} to {}. x is {} and y is {}. Eps {}, diff {}", a, b,
74 // x, y, eps, diff);
75
76 if (diff < -eps)
77 {
78 return std::weak_ordering::greater;
79 }
80 if (diff > eps)
81 {
82 return std::weak_ordering::less;
83 }
84 return std::weak_ordering::equivalent;
85 }

◆ operator==()

bool NumLib::Time::operator== ( Time const & x) const
inlineconstexpr

Definition at line 87 of file Time.h.

88 {
89 return (*this <=> x) == std::weak_ordering::equivalent;
90 }

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
Time const & t )
friend

Definition at line 92 of file Time.h.

93 {
94 auto const precision = os.precision();
95 return os << std::setprecision(
96 std::numeric_limits<double>::max_digits10)
97 << t() << std::setprecision(precision);
98 }

Member Data Documentation

◆ value_

MathLib::KahanSum NumLib::Time::value_
private

Definition at line 101 of file Time.h.

Referenced by operator()(), operator+=(), and operator-=().


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