OGS
NumLib::Time Struct Reference

Detailed Description

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

35: value_{time} {}
MathLib::KahanSum value_
Definition Time.h:102

Member Function Documentation

◆ operator()()

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

Definition at line 37 of file Time.h.

37{ return value_(); }

References value_.

◆ operator+()

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

Definition at line 45 of file Time.h.

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

◆ operator+=()

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

Definition at line 39 of file Time.h.

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

References value_.

◆ operator-()

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

Definition at line 58 of file Time.h.

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

◆ operator-=()

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

Definition at line 52 of file Time.h.

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

References value_.

◆ operator<=>()

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

Definition at line 65 of file Time.h.

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

◆ operator==()

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

Definition at line 88 of file Time.h.

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

Friends And Related Symbol Documentation

◆ operator<<

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

Definition at line 93 of file Time.h.

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

Member Data Documentation

◆ value_

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

Definition at line 102 of file Time.h.

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


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