Loading...
Searching...
No Matches
gpr::derivatives::CountedReal Class Reference

#include <gpr/derivatives/CountedReal.h>

Public Member Functions

 CountedReal ()=default
 CountedReal (double value)
double value () const noexcept
CountedReal & operator+= (const CountedReal &other)
CountedReal & operator-= (const CountedReal &other)
CountedReal & operator*= (const CountedReal &other)
CountedReal & operator/= (const CountedReal &other)

Friends

CountedReal operator+ (CountedReal a, const CountedReal &b)
CountedReal operator- (CountedReal a, const CountedReal &b)
CountedReal operator* (CountedReal a, const CountedReal &b)
CountedReal operator/ (CountedReal a, const CountedReal &b)
CountedReal operator- (const CountedReal &a)
CountedReal operator+ (const CountedReal &a)
bool operator< (const CountedReal &a, const CountedReal &b)
bool operator> (const CountedReal &a, const CountedReal &b)
bool operator<= (const CountedReal &a, const CountedReal &b)
bool operator>= (const CountedReal &a, const CountedReal &b)
bool operator== (const CountedReal &a, const CountedReal &b)
bool operator!= (const CountedReal &a, const CountedReal &b)
CountedReal exp (const CountedReal &a)
CountedReal sqrt (const CountedReal &a)
CountedReal pow (const CountedReal &a, const CountedReal &b)
CountedReal abs (const CountedReal &a)
bool isfinite (const CountedReal &a)

Detailed Description

A double whose arithmetic increments operationCounts(). It carries no derivative and rounds each operation as double does; Eigen does not vectorise it, so reductions can associate differently from a double evaluation of the same expression.

Definition at line 43 of file CountedReal.h.

Constructor & Destructor Documentation

◆ CountedReal() [1/2]

gpr::derivatives::CountedReal::CountedReal ( )
default

◆ CountedReal() [2/2]

gpr::derivatives::CountedReal::CountedReal ( double value)
inline

Definition at line 46 of file CountedReal.h.

46: value_(value) { } // NOLINT: implicit by design
double value() const noexcept
Definition CountedReal.h:48

Member Function Documentation

◆ operator*=()

CountedReal & gpr::derivatives::CountedReal::operator*= ( const CountedReal & other)
inline

Definition at line 65 of file CountedReal.h.

66 {
68 value_ *= other.value_;
69 return *this;
70 }
OperationCounts & operationCounts() noexcept
Definition CountedReal.h:33

◆ operator+=()

CountedReal & gpr::derivatives::CountedReal::operator+= ( const CountedReal & other)
inline

Definition at line 53 of file CountedReal.h.

54 {
56 value_ += other.value_;
57 return *this;
58 }
std::uint64_t add
additions, subtractions and negations
Definition CountedReal.h:16

◆ operator-=()

CountedReal & gpr::derivatives::CountedReal::operator-= ( const CountedReal & other)
inline

Definition at line 59 of file CountedReal.h.

60 {
62 value_ -= other.value_;
63 return *this;
64 }

◆ operator/=()

CountedReal & gpr::derivatives::CountedReal::operator/= ( const CountedReal & other)
inline

Definition at line 71 of file CountedReal.h.

72 {
74 value_ /= other.value_;
75 return *this;
76 }

◆ value()

double gpr::derivatives::CountedReal::value ( ) const
inlinenodiscardnoexcept

Definition at line 48 of file CountedReal.h.

49 {
50 return value_;
51 }

◆ abs

CountedReal abs ( const CountedReal & a)
friend

Definition at line 141 of file CountedReal.h.

142 {
143 return CountedReal(std::abs(a.value_));
144 }

◆ exp

CountedReal exp ( const CountedReal & a)
friend

Definition at line 126 of file CountedReal.h.

127 {
129 return CountedReal(std::exp(a.value_));
130 }

◆ isfinite

bool isfinite ( const CountedReal & a)
friend

Definition at line 145 of file CountedReal.h.

146 {
147 return std::isfinite(a.value_);
148 }

◆ operator!=

bool operator!= ( const CountedReal & a,
const CountedReal & b )
friend

Definition at line 122 of file CountedReal.h.

123 {
124 return a.value_ != b.value_;
125 }

◆ operator*

CountedReal operator* ( CountedReal a,
const CountedReal & b )
friend

Definition at line 85 of file CountedReal.h.

86 {
87 return a *= b;
88 }

◆ operator+ [1/2]

CountedReal operator+ ( const CountedReal & a)
friend

Definition at line 98 of file CountedReal.h.

99 {
100 return a;
101 }

◆ operator+ [2/2]

CountedReal operator+ ( CountedReal a,
const CountedReal & b )
friend

Definition at line 77 of file CountedReal.h.

78 {
79 return a += b;
80 }

◆ operator- [1/2]

CountedReal operator- ( const CountedReal & a)
friend

Definition at line 93 of file CountedReal.h.

94 {
96 return CountedReal(-a.value_);
97 }

◆ operator- [2/2]

CountedReal operator- ( CountedReal a,
const CountedReal & b )
friend

Definition at line 81 of file CountedReal.h.

82 {
83 return a -= b;
84 }

◆ operator/

CountedReal operator/ ( CountedReal a,
const CountedReal & b )
friend

Definition at line 89 of file CountedReal.h.

90 {
91 return a /= b;
92 }

◆ operator<

bool operator< ( const CountedReal & a,
const CountedReal & b )
friend

Definition at line 102 of file CountedReal.h.

103 {
104 return a.value_ < b.value_;
105 }

◆ operator<=

bool operator<= ( const CountedReal & a,
const CountedReal & b )
friend

Definition at line 110 of file CountedReal.h.

111 {
112 return a.value_ <= b.value_;
113 }

◆ operator==

bool operator== ( const CountedReal & a,
const CountedReal & b )
friend

Definition at line 118 of file CountedReal.h.

119 {
120 return a.value_ == b.value_;
121 }

◆ operator>

bool operator> ( const CountedReal & a,
const CountedReal & b )
friend

Definition at line 106 of file CountedReal.h.

107 {
108 return a.value_ > b.value_;
109 }

◆ operator>=

bool operator>= ( const CountedReal & a,
const CountedReal & b )
friend

Definition at line 114 of file CountedReal.h.

115 {
116 return a.value_ >= b.value_;
117 }

◆ pow

CountedReal pow ( const CountedReal & a,
const CountedReal & b )
friend

Definition at line 136 of file CountedReal.h.

137 {
139 return CountedReal(std::pow(a.value_, b.value_));
140 }

◆ sqrt

CountedReal sqrt ( const CountedReal & a)
friend

Definition at line 131 of file CountedReal.h.

132 {
134 return CountedReal(std::sqrt(a.value_));
135 }

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