OGS
NumLib::Time Struct Reference

Detailed Description

Definition at line 26 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 28 of file Time.h.

28: value_{time} {}
MathLib::KahanSum value_
Definition Time.h:95

References value_.

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

Member Function Documentation

◆ operator()()

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

Definition at line 30 of file Time.h.

30{ return value_(); }

References value_.

◆ operator+()

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

Definition at line 38 of file Time.h.

39 {
40 Time result = *this;
41 result += increment;
42 return result;
43 }
constexpr Time(double const time)
Definition Time.h:28

References Time().

◆ operator+=()

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

Definition at line 32 of file Time.h.

33 {
34 value_ += increment;
35 return *this;
36 }

References Time(), and value_.

◆ operator-()

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

Definition at line 51 of file Time.h.

52 {
53 Time result = *this;
54 result -= decrement;
55 return result;
56 }

References Time().

◆ operator-=()

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

Definition at line 45 of file Time.h.

46 {
47 value_ -= decrement;
48 return *this;
49 }

References Time(), and value_.

◆ operator<=>()

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

Definition at line 58 of file Time.h.

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

References Time().

◆ operator==()

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

Definition at line 81 of file Time.h.

82 {
83 return (*this <=> x) == std::weak_ordering::equivalent;
84 }

References Time().

◆ operator<<

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

Definition at line 86 of file Time.h.

87 {
88 auto const precision = os.precision();
89 return os << std::setprecision(
90 std::numeric_limits<double>::max_digits10)
91 << t() << std::setprecision(precision);
92 }

References Time().

Member Data Documentation

◆ value_

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

Definition at line 95 of file Time.h.

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


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