Skip to content

Commit

Permalink
Merge pull request #9 from njoy/fix/map
Browse files Browse the repository at this point in the history
Updated so now we compose a hana::map instead of inherit from it.
  • Loading branch information
jlconlin authored Jul 14, 2020
2 parents c02e008 + 112a244 commit e04ed6e
Show file tree
Hide file tree
Showing 11 changed files with 216 additions and 163 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/ContinuousIntegration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# GitHub workflow to enable continuous integratoin
name: Continuous Integration

# This workflow is triggered on pushes and pull requests to the repository.
on:
push:
branches: '**'
pull_request:
branches: 'master'

jobs:
build:
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ ubuntu-18.04, macos-10.15 ]
cxx: [ g++-9, clang++ ]
build_type: [ Debug, Release ]

steps:
- name: which CXX
run: |
which ${{matrix.cxx}}
${{matrix.cxx}} --version
- uses: actions/checkout@v2
- name: mkdir bin
run: mkdir bin
- name: cmake
run: cmake -D CMAKE_CXX_COMPILER=`which ${{matrix.cxx}}` -D CMAKE_BUILD_TYPE=${{matrix.build_type}} ..
working-directory: ./bin
- name: make
run: make
working-directory: ./bin
- name: ctest
run: ctest -j2
working-directory: ./bin
51 changes: 25 additions & 26 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,6 @@ set( constants_AppleClang_Darwin_link_time_optimization_flags "-flto" )
set( constants_AppleClang_Darwin_profile_use_flags "-fprofile-use='${CMAKE_BINARY_DIR}/profiling'" )
set( constants_AppleClang_Darwin_nonportable_optimization_flags "-march=native" )
set( constants_AppleClang_Darwin_static_flags "-static" )
set( constants_GNU_Windows_common_flags "-Wno-subobject-linkage" "-Wall" "-Wextra" "-Wpedantic" "-std=c++17" )
set( constants_GNU_Windows_DEBUG_flags "-O0" "-g" "-gdwarf-3" "-fsignaling-nans" )
set( constants_GNU_Windows_RELEASE_flags "-O3" "-DNDEBUG" )
set( constants_GNU_Windows_strict_flags "-Werror" )
set( constants_GNU_Windows_coverage_flags "--coverage" )
set( constants_GNU_Windows_subproject_flags )
set( constants_GNU_Windows_base_project_flags )
set( constants_GNU_Windows_profile_generate_flags "-fprofile-generate='${CMAKE_BINARY_DIR}/profiling'" )
set( constants_GNU_Windows_link_time_optimization_flags "-flto" )
set( constants_GNU_Windows_profile_use_flags "-fprofile-use='${CMAKE_BINARY_DIR}/profiling'" )
set( constants_GNU_Windows_nonportable_optimization_flags "-march=native" )
set( constants_GNU_Windows_static_flags "-static" )
set( constants_GNU_CYGWIN_common_flags "-Wno-subobject-linkage" "-Wall" "-Wextra" "-Wpedantic" "-std=gnu++17" )
set( constants_GNU_CYGWIN_DEBUG_flags "-O0" "-g" "-gdwarf-3" "-fsignaling-nans" )
set( constants_GNU_CYGWIN_RELEASE_flags "-O3" "-DNDEBUG" )
Expand Down Expand Up @@ -151,6 +139,18 @@ set( constants_GNU_MinGW_link_time_optimization_flags "-flto" )
set( constants_GNU_MinGW_profile_use_flags "-fprofile-use='${CMAKE_BINARY_DIR}/profiling'" )
set( constants_GNU_MinGW_nonportable_optimization_flags "-march=native" )
set( constants_GNU_MinGW_static_flags "-static" )
set( constants_GNU_Windows_common_flags "-Wno-subobject-linkage" "-Wall" "-Wextra" "-Wpedantic" "-std=c++17" )
set( constants_GNU_Windows_DEBUG_flags "-O0" "-g" "-gdwarf-3" "-fsignaling-nans" )
set( constants_GNU_Windows_RELEASE_flags "-O3" "-DNDEBUG" )
set( constants_GNU_Windows_strict_flags "-Werror" )
set( constants_GNU_Windows_coverage_flags "--coverage" )
set( constants_GNU_Windows_subproject_flags )
set( constants_GNU_Windows_base_project_flags )
set( constants_GNU_Windows_profile_generate_flags "-fprofile-generate='${CMAKE_BINARY_DIR}/profiling'" )
set( constants_GNU_Windows_link_time_optimization_flags "-flto" )
set( constants_GNU_Windows_profile_use_flags "-fprofile-use='${CMAKE_BINARY_DIR}/profiling'" )
set( constants_GNU_Windows_nonportable_optimization_flags "-march=native" )
set( constants_GNU_Windows_static_flags "-static" )
set( constants_GNU_Darwin_common_flags "-Wno-subobject-linkage" "-Wall" "-Wextra" "-Wpedantic" "-std=c++17" )
set( constants_GNU_Darwin_DEBUG_flags "-O0" "-g" "-gdwarf-3" "-fsignaling-nans" )
set( constants_GNU_Darwin_RELEASE_flags "-O3" "-DNDEBUG" )
Expand All @@ -163,18 +163,6 @@ set( constants_GNU_Darwin_link_time_optimization_flags "-flto" )
set( constants_GNU_Darwin_profile_use_flags "-fprofile-use='${CMAKE_BINARY_DIR}/profiling'" )
set( constants_GNU_Darwin_nonportable_optimization_flags "-march=native" )
set( constants_GNU_Darwin_static_flags "-static" )
set( constants_Clang_Windows_common_flags "-stdlib=libc++" "-Wall" "-Wextra" "-Wpedantic" "-std=c++17" )
set( constants_Clang_Windows_DEBUG_flags "-O0" "-g" "-gdwarf-3" )
set( constants_Clang_Windows_RELEASE_flags "-O3" "-DNDEBUG" )
set( constants_Clang_Windows_strict_flags "-Werror" )
set( constants_Clang_Windows_coverage_flags "--coverage" )
set( constants_Clang_Windows_subproject_flags )
set( constants_Clang_Windows_base_project_flags )
set( constants_Clang_Windows_profile_generate_flags "-fprofile-generate='${CMAKE_BINARY_DIR}/profiling'" )
set( constants_Clang_Windows_link_time_optimization_flags "-flto" )
set( constants_Clang_Windows_profile_use_flags "-fprofile-use='${CMAKE_BINARY_DIR}/profiling'" )
set( constants_Clang_Windows_nonportable_optimization_flags "-march=native" )
set( constants_Clang_Windows_static_flags "-static" )
set( constants_Clang_CYGWIN_common_flags "-Wno-subobject-linkage" "-Wall" "-Wextra" "-Wpedantic" "-std=gnu++17" )
set( constants_Clang_CYGWIN_DEBUG_flags "-O0" "-g" "-gdwarf-3" "-fsignaling-nans" )
set( constants_Clang_CYGWIN_RELEASE_flags "-O3" "-DNDEBUG" )
Expand Down Expand Up @@ -211,6 +199,18 @@ set( constants_Clang_MinGW_link_time_optimization_flags "-flto" )
set( constants_Clang_MinGW_profile_use_flags "-fprofile-use='${CMAKE_BINARY_DIR}/profiling'" )
set( constants_Clang_MinGW_nonportable_optimization_flags "-march=native" )
set( constants_Clang_MinGW_static_flags "-static" )
set( constants_Clang_Windows_common_flags "-stdlib=libc++" "-Wall" "-Wextra" "-Wpedantic" "-std=c++17" )
set( constants_Clang_Windows_DEBUG_flags "-O0" "-g" "-gdwarf-3" )
set( constants_Clang_Windows_RELEASE_flags "-O3" "-DNDEBUG" )
set( constants_Clang_Windows_strict_flags "-Werror" )
set( constants_Clang_Windows_coverage_flags "--coverage" )
set( constants_Clang_Windows_subproject_flags )
set( constants_Clang_Windows_base_project_flags )
set( constants_Clang_Windows_profile_generate_flags "-fprofile-generate='${CMAKE_BINARY_DIR}/profiling'" )
set( constants_Clang_Windows_link_time_optimization_flags "-flto" )
set( constants_Clang_Windows_profile_use_flags "-fprofile-use='${CMAKE_BINARY_DIR}/profiling'" )
set( constants_Clang_Windows_nonportable_optimization_flags "-march=native" )
set( constants_Clang_Windows_static_flags "-static" )
set( constants_Clang_Darwin_common_flags "-stdlib=libc++" "-Wall" "-Wextra" "-Wpedantic" "-std=c++17" )
set( constants_Clang_Darwin_DEBUG_flags "-O0" "-g" "-gdwarf-3" )
set( constants_Clang_Darwin_RELEASE_flags "-O3" "-DNDEBUG" )
Expand Down Expand Up @@ -292,8 +292,7 @@ target_sources( constants INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/src/constants.h
"${CMAKE_CURRENT_SOURCE_DIR}/src/constants/tags.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/constants/CODATA2018.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/constants/testing/src/defineReferenceValues.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/constants/testing/src/toValue.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/constants/src/addUncertainty.hpp" )
"${CMAKE_CURRENT_SOURCE_DIR}/src/constants/testing/src/toValue.hpp" )

target_include_directories( constants INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/src src/ )

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build Status](http://jenkins.njoy21.io:8080/buildStatus/icon?job=constants)](http://jenkins.njoy21.io:8080/job/constants/)
![Continuous Integration](https://github.com/njoy/constants/workflows/Continuous%20Integration/badge.svg)

# constants
This repository contains a collection of mathematical and physical constants. Additional information about the constants provided—and their values— see the associated README files.
Expand Down
3 changes: 1 addition & 2 deletions metaconfigure/description.json
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,7 @@
"src/constants/tags.hpp",
"src/constants/CODATA2018.hpp",
"src/constants/testing/src/defineReferenceValues.hpp",
"src/constants/testing/src/toValue.hpp",
"src/constants/src/addUncertainty.hpp"
"src/constants/testing/src/toValue.hpp"
],
"ignore pattern": "$^",
"implementation files": [],
Expand Down
1 change: 0 additions & 1 deletion src/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ namespace constants {
#include "constants/math.hpp"
#include "constants/tags.hpp"
#include "constants/map.hpp"
#include "constants/src/addUncertainty.hpp"

} // namespace constants
} // namespace njoy
Expand Down
120 changes: 60 additions & 60 deletions src/constants/CODATA2014.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,69 +6,69 @@
namespace njoy {
namespace constants {

static constexpr auto CODATA2014 = addUncertainty(
hana::make_map(
hana::make_pair( avogadro , 6.022140857e23/mole ),
hana::make_pair( boltzmann , 1.38064852e-23*joule/kelvin ),
hana::make_pair( conductanceQuantum, 7.7480917310e-5*siemens ),
hana::make_pair( electric, 8.854187817e-12*farad/meter ),
hana::make_pair( electronRadius, 2.8179403227e-15*meter ),
hana::make_pair( elementaryCharge, 1.6021766208e-19*coulomb ),
hana::make_pair( faraday, 9.648533289e4*coulomb/mole ),
hana::make_pair( fineStructure, 7.2973525664e-3*meter/meter ),
hana::make_pair( magnetic, 1.2566370614e-6*newton/ampere/ampere ),
hana::make_pair( magneticFluxQuantum, 2.067833831e-15*weber ),
hana::make_pair( molarGas, 8.3144598*joule/mole/kelvin ),
hana::make_pair( newtonianGravitation,
6.67408e-11*meter*meter*meter/kilo( gram )/second/second ),
hana::make_pair( planck , 6.626070040e-34*joule*second ),
hana::make_pair( reducedPlanck, 1.054571800e-34*joule*second ),
hana::make_pair( rydberg, 1.0973731568508e7/meter ),
hana::make_pair( speedOfLight , 2.99792458e8*meter/second ),
hana::make_pair( stefanBoltzmann,
5.670367e-8*watt/meter/meter/kelvin/kelvin/kelvin/kelvin ),
static constexpr auto values = hana::make_map(
hana::make_pair( avogadro , 6.022140857e23/mole ),
hana::make_pair( boltzmann , 1.38064852e-23*joule/kelvin ),
hana::make_pair( conductanceQuantum, 7.7480917310e-5*siemens ),
hana::make_pair( electric, 8.854187817e-12*farad/meter ),
hana::make_pair( electronRadius, 2.8179403227e-15*meter ),
hana::make_pair( elementaryCharge, 1.6021766208e-19*coulomb ),
hana::make_pair( faraday, 9.648533289e4*coulomb/mole ),
hana::make_pair( fineStructure, 7.2973525664e-3*meter/meter ),
hana::make_pair( magnetic, 1.2566370614e-6*newton/ampere/ampere ),
hana::make_pair( magneticFluxQuantum, 2.067833831e-15*weber ),
hana::make_pair( molarGas, 8.3144598*joule/mole/kelvin ),
hana::make_pair( newtonianGravitation,
6.67408e-11*meter*meter*meter/kilo( gram )/second/second ),
hana::make_pair( planck , 6.626070040e-34*joule*second ),
hana::make_pair( reducedPlanck, 1.054571800e-34*joule*second ),
hana::make_pair( rydberg, 1.0973731568508e7/meter ),
hana::make_pair( speedOfLight , 2.99792458e8*meter/second ),
hana::make_pair( stefanBoltzmann,
5.670367e-8*watt/meter/meter/kelvin/kelvin/kelvin/kelvin ),

// Masses
hana::make_pair( electronMass , 9.10938356e-31*kilo( gram ) ),
hana::make_pair( neutronMass , 1.674927471e-27*kilo( gram ) ),
hana::make_pair( protonMass , 1.672621898e-27*kilo( gram ) ),
hana::make_pair( deuteronMass , 3.343583719e-27*kilo( gram ) ),
hana::make_pair( helionMass , 5.0064127000e-27*kilo( gram ) ),
hana::make_pair( tritonMass , 5.007356665e-27*kilo( gram ) ),
hana::make_pair( alphaMass , 6.644657230e-27*kilo( gram ) )
),
// Masses
hana::make_pair( electronMass , 9.10938356e-31*kilo( gram ) ),
hana::make_pair( neutronMass , 1.674927471e-27*kilo( gram ) ),
hana::make_pair( protonMass , 1.672621898e-27*kilo( gram ) ),
hana::make_pair( deuteronMass , 3.343583719e-27*kilo( gram ) ),
hana::make_pair( helionMass , 5.0064127000e-27*kilo( gram ) ),
hana::make_pair( tritonMass , 5.007356665e-27*kilo( gram ) ),
hana::make_pair( alphaMass , 6.644657230e-27*kilo( gram ) )
);
// Uncertainties
hana::make_map(
hana::make_pair( avogadro , 0.000000074e23/mole ),
hana::make_pair( boltzmann , 0.00000079e-23*joule/kelvin ),
hana::make_pair( conductanceQuantum, 1.8E-14*siemens ),
hana::make_pair( electric, 0.0*farad/meter ),
hana::make_pair( electronRadius, 1.9e-24*meter ),
hana::make_pair( elementaryCharge, 0.0000000098e-19*coulomb ),
hana::make_pair( faraday, 5.9e-4*coulomb/mole ),
hana::make_pair( fineStructure, 1.7e-12*meter/meter ),
hana::make_pair( magnetic, 0.0*newton/ampere/ampere ),
hana::make_pair( magneticFluxQuantum, 1.3e-23*weber ),
hana::make_pair( molarGas, 4.8e-6*joule/mole/kelvin ),
hana::make_pair( newtonianGravitation,
0.00031e-11*meter*meter*meter/kilo( gram )/second/second ),
hana::make_pair( planck , 0.000000081e-34*joule*second ),
hana::make_pair( reducedPlanck, 0.000000013e-34*joule*second ),
hana::make_pair( rydberg, 6.5e-5/meter ),
hana::make_pair( speedOfLight , 0.0*meter/second ),
hana::make_pair( stefanBoltzmann,
1.3e-13*watt/meter/meter/kelvin/kelvin/kelvin/kelvin ),
static constexpr auto uncertainties = hana::make_map(
hana::make_pair( avogadro , 0.000000074e23/mole ),
hana::make_pair( boltzmann , 0.00000079e-23*joule/kelvin ),
hana::make_pair( conductanceQuantum, 1.8E-14*siemens ),
hana::make_pair( electric, 0.0*farad/meter ),
hana::make_pair( electronRadius, 1.9e-24*meter ),
hana::make_pair( elementaryCharge, 0.0000000098e-19*coulomb ),
hana::make_pair( faraday, 5.9e-4*coulomb/mole ),
hana::make_pair( fineStructure, 1.7e-12*meter/meter ),
hana::make_pair( magnetic, 0.0*newton/ampere/ampere ),
hana::make_pair( magneticFluxQuantum, 1.3e-23*weber ),
hana::make_pair( molarGas, 4.8e-6*joule/mole/kelvin ),
hana::make_pair( newtonianGravitation,
0.00031e-11*meter*meter*meter/kilo( gram )/second/second ),
hana::make_pair( planck , 0.000000081e-34*joule*second ),
hana::make_pair( reducedPlanck, 0.000000013e-34*joule*second ),
hana::make_pair( rydberg, 6.5e-5/meter ),
hana::make_pair( speedOfLight , 0.0*meter/second ),
hana::make_pair( stefanBoltzmann,
1.3e-13*watt/meter/meter/kelvin/kelvin/kelvin/kelvin ),

// Masses
hana::make_pair( electronMass , 0.00000011e-31*kilo( gram ) ),
hana::make_pair( neutronMass , 0.000000021e-27*kilo( gram ) ),
hana::make_pair( protonMass , 0.000000021e-27*kilo( gram ) ),
hana::make_pair( deuteronMass , 0.000000041e-27*kilo( gram ) ),
hana::make_pair( helionMass , 0.000000062e-27*kilo( gram ) ),
hana::make_pair( tritonMass , 0.000000062e-27*kilo( gram ) ),
hana::make_pair( alphaMass , 0.000000082e-27*kilo( gram ) )
)
);
// Masses
hana::make_pair( electronMass , 0.00000011e-31*kilo( gram ) ),
hana::make_pair( neutronMass , 0.000000021e-27*kilo( gram ) ),
hana::make_pair( protonMass , 0.000000021e-27*kilo( gram ) ),
hana::make_pair( deuteronMass , 0.000000041e-27*kilo( gram ) ),
hana::make_pair( helionMass , 0.000000062e-27*kilo( gram ) ),
hana::make_pair( tritonMass , 0.000000062e-27*kilo( gram ) ),
hana::make_pair( alphaMass , 0.000000082e-27*kilo( gram ) )
);

static constexpr auto CODATA2014 = Map_t( values, uncertainties );

} // namespace constants
} // namespace njoy
Expand Down
4 changes: 2 additions & 2 deletions src/constants/CODATA2014/test/CODATA2014.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void checkMap( MAP& map ){
auto referenceValues =
testing::defineReferenceValues( std::ifstream("CODATA2014.txt") );

hana::for_each( hana::keys( map ),
hana::for_each( hana::keys( map.value ),
[&]( auto&& key ){
auto refKey = stringFor[ key ];

Expand All @@ -64,7 +64,7 @@ SCENARIO("test all the constants"){

checkMap( CODATA2014 );

auto aliasMap = addUncertainty(
auto aliasMap = Map_t(
hana::make_map(
hana::make_pair( k, CODATA2014[ k ] ),
hana::make_pair( h, CODATA2014[ h ] ),
Expand Down
Loading

0 comments on commit e04ed6e

Please sign in to comment.