SpECTRE  v2024.04.12
Rational Class Reference

A rational number. More...

#include <Rational.hpp>

Public Member Functions

 Rational (std::int32_t numerator, std::int32_t denominator)
 
template<typename T , Requires< tt::is_integer_v< T > > = nullptr>
 Rational (const T integral_value)
 
std::int32_t numerator () const
 
std::int32_t denominator () const
 
double value () const
 
Rational inverse () const
 
Rationaloperator+= (const Rational &other)
 
Rationaloperator-= (const Rational &other)
 
Rationaloperator*= (const Rational &other)
 
Rationaloperator/= (const Rational &other)
 
void pup (PUP::er &p)
 

Friends

Rational operator- (Rational r)
 

Detailed Description

A rational number.

This serves as a faster replacement for boost::rational<std::int32_t>. As of Boost 1.65.0, arithmetic operators average about twice as fast, and ordering operators are about eight times as fast.


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