The Gaudi Framework  master (37c0b60a)
Counters.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #pragma once
12 
20 #include <chrono>
21 #include <cmath>
22 
23 namespace Gaudi {
24  namespace Accumulators {
25  /*
26  * std::chrono::duration only supports arithmetic operations that preserve the unit
27  * of time, e.g. there are no operations that would result in units of ms^2. This can
28  * be inconvenient for the use in general purpose libraries like Gaudi::Accumulators.
29  * This header provides the missing operators.
30  */
31 
33  template <class Rep, class Period>
35  return std::chrono::duration<Rep, Period>( static_cast<Rep>( std::round( std::sqrt( d.count() ) ) ) );
36  }
37 
39  template <class Rep1, class Rep2, class Period>
41  return std::chrono::duration<std::common_type_t<Rep1, Rep2>, Period>( lhs.count() * rhs.count() );
42  }
43  } // namespace Accumulators
44 } // namespace Gaudi
45 
46 #include <Gaudi/Accumulators.h>
47 #include <Gaudi/Chrono/ChronoIO.h>
Gaudi::Accumulators::sqrt
auto sqrt(std::chrono::duration< Rep, Period > d)
sqrt for std::chrono::duration
Definition: Counters.h:34
Gaudi::Accumulators::operator*
auto operator*(const std::chrono::duration< Rep1, Period > &lhs, const std::chrono::duration< Rep2, Period > &rhs)
Multiplication of two std::chrono::duration objects with same Period.
Definition: Counters.h:40
ChronoIO.h
std::chrono::duration
std::sqrt
T sqrt(T... args)
Gaudi
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition: __init__.py:1
Accumulators.h
std::round
T round(T... args)
std::chrono::duration::count
T count(T... args)