Skip to content

Instantly share code, notes, and snippets.

View 2b-t's full-sized avatar

Tobit Flatscher 2b-t

View GitHub Profile
@2b-t
2b-t / is_almost_equal_ulps.hpp
Last active November 19, 2023 14:31
Constexpr units in the last place (ULP) floating number comparison in C++20 similar to GoogleTest
/**
* \file is_almost_equal_ulps.hpp
* \brief Constexpr implementation of a floating number point comparison based on units in last place (ULPs)
* \mainpage Contains traits and a constexpr function for comparing two floating point numbers based on units
* in the last place (ULP) similar to the implementation in GoogleTest but more modular and constexpr:
* https://github.com/google/googletest/blob/main/googletest/include/gtest/internal/gtest-internal.h
*/
#ifndef IS_ALMOST_EQUAL_ULPS_HPP
#define IS_ALMOST_EQUAL_ULPS_HPP
@2b-t
2b-t / mpi_type.hpp
Last active August 22, 2022 05:51
MPI data type template in C++17
/**
* \file mpi_type.hpp
* \brief Function for automatically determining MPI data type to a constexpr
* \mainpage Contains a template function that helps determining the corresponding MPI message data type
* that can be found on \ref https://www.mpich.org/static/docs/latest/www3/Constants.html
* to a constexpr. This way the code may already be simplified at compile time.
*/
#ifndef MPI_TYPE_HPP_INCLUDED
#define MPI_TYPE_HPP_INCLUDED