NumCpp  2.4.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
lcm.hpp
Go to the documentation of this file.
1 #pragma once
29 
30 #if defined(__cpp_lib_gcd_lcm) || !defined(NO_USE_BOOST)
31 
34 #include "NumCpp/NdArray.hpp"
35 
36 #ifndef NO_USE_BOOST
37 #include "boost/integer/common_factor_rt.hpp"
38 #endif
39 
40 #ifdef __cpp_lib_gcd_lcm
41 #include <numeric>
42 #endif
43 
44 namespace nc
45 {
46  //============================================================================
47  // Method Description:
59  template<typename dtype>
60  dtype lcm(dtype inValue1, dtype inValue2) noexcept
61  {
62  STATIC_ASSERT_INTEGER(dtype);
63 
64 #ifdef __cpp_lib_gcd_lcm
65  return std::lcm(inValue1, inValue2);
66 #else
67  return boost::integer::lcm(inValue1, inValue2);
68 #endif
69  }
70 
71 #ifndef NO_USE_BOOST
72  //============================================================================
73  // Method Description:
83  template<typename dtype>
84  dtype lcm(const NdArray<dtype>& inArray)
85  {
86  STATIC_ASSERT_INTEGER(dtype);
87 
88  return boost::integer::lcm_range(inArray.cbegin(), inArray.cend()).first;
89  }
90 #endif // #ifndef NO_USE_BOOST
91 } // namespace nc
92 
93 #endif // #if defined(__cpp_lib_gcd_lcm) || !defined(NO_USE_BOOST)
STATIC_ASSERT_INTEGER
#define STATIC_ASSERT_INTEGER(dtype)
Definition: StaticAsserts.hpp:40
StaticAsserts.hpp
Error.hpp
nc::NdArray< dtype >
NdArray.hpp
nc::lcm
dtype lcm(dtype inValue1, dtype inValue2) noexcept
Definition: lcm.hpp:60
nc::NdArray::cend
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1487
nc::lcm
dtype lcm(const NdArray< dtype > &inArray)
Definition: lcm.hpp:84
nc
Definition: Coordinate.hpp:44
nc::NdArray::cbegin
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1143