NumCpp  2.12.1
A Templatized Header Only C++ Implementation of the Python NumPy Library
lcm.hpp
Go to the documentation of this file.
1
28#pragma once
29
30#include <numeric>
31
32#if defined(__cpp_lib_gcd_lcm) || !defined(NUMCPP_NO_USE_BOOST)
33
36#include "NumCpp/NdArray.hpp"
37
38#ifndef NUMCPP_NO_USE_BOOST
39#include "boost/integer/common_factor_rt.hpp"
40#endif
41
42namespace nc
43{
44 //============================================================================
45 // Method Description:
56 template<typename dtype>
57 dtype lcm(dtype inValue1, dtype inValue2) noexcept
58 {
60
61#ifdef __cpp_lib_gcd_lcm
62 return std::lcm(inValue1, inValue2);
63#else
64 return boost::integer::lcm(inValue1, inValue2);
65#endif
66 }
67
68#ifndef NUMCPP_NO_USE_BOOST
69 //============================================================================
70 // Method Description:
79 template<typename dtype>
80 dtype lcm(const NdArray<dtype>& inArray)
81 {
83
84 return boost::integer::lcm_range(inArray.cbegin(), inArray.cend()).first;
85 }
86#endif // #ifndef NUMCPP_NO_USE_BOOST
87} // namespace nc
88
89#endif // #if defined(__cpp_lib_gcd_lcm) || !defined(NUMCPP_NO_USE_BOOST)
#define STATIC_ASSERT_INTEGER(dtype)
Definition: StaticAsserts.hpp:43
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:139
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1365
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1673
Definition: Cartesian.hpp:40
dtype lcm(dtype inValue1, dtype inValue2) noexcept
Definition: lcm.hpp:57
dtype lcm(const NdArray< dtype > &inArray)
Definition: lcm.hpp:80