HILA
Loading...
Searching...
No Matches
extended.h File Reference

This files containts definitions for the extended precision class that allows for high precision reductions using Kahan-Babushka-Klein summation. More...

#include "plumbing/defs.h"
Include dependency graph for extended.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  hila
 Implement hila::swap for gauge fields.
 

Functions

template<typename T , std::enable_if_t< std::is_arithmetic< T >::value, int > = 0>
ExtendedPrecision operator+ (ExtendedPrecision a, const T b)
 ExtendedPrecision precision operators + - * / – also ext * arithm.
 
template<typename A , typename B , std::enable_if_t< hila::AorB_extended< A, B >::value, int > = 0>
bool operator== (const A &a, const B &b)
 comparison operators
 

Detailed Description

This files containts definitions for the extended precision class that allows for high precision reductions using Kahan-Babushka-Klein summation.

Uses internally three double precision variables to store the value and compensation. Precision can be > 15 orders of magnitude better than plain doble.

Use:

ExtendedPrecision s1 = 0, s2 = 0;
onsites(ALL) {
s1 += <double/float/int -valued expression>;
s2 += <some other expression>
}
// below subtraction and comparison is done in extended precision
if (s1 == s2)
hila::out0 << "s1 equals s2\n";
else
hila::out0 << "s1 is " << (s1 > s2) ? "greater" : "less"
<< " than s2, with difference " << s1 - s2 << '\n';
constexpr Parity ALL
bit pattern: 011
std::ostream out0
This writes output only from main process (node 0)

Class implements basic arithmetics ( + - * / ), assignments (= += *=) and comparison ops for ExtendedPrecision types. ExtendedPrecision is not automatically downgraded to double in order to avoid accidental loss of accuracy.

To get a double approximation of the value use

s1.to_double()
// or equvalently explicit casting
static_cast<double>(s1)

Definition in file extended.h.