NumCpp  2.18.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
Loading...
Searching...
No Matches
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
35#include "NumCpp/NdArray.hpp"
36
37#ifndef NUMCPP_NO_USE_BOOST
38#include "boost/integer/common_factor_rt.hpp"
39#endif
40
41namespace nc
42{
43 //============================================================================
44 // Method Description:
55 template<typename dtype>
56 dtype lcm(dtype inValue1, dtype inValue2) noexcept
57 {
59
60#ifdef __cpp_lib_gcd_lcm
61 return std::lcm(inValue1, inValue2);
62#else
63 return boost::integer::lcm(inValue1, inValue2);
64#endif
65 }
66
67#ifndef NUMCPP_NO_USE_BOOST
68 //============================================================================
69 // Method Description:
78 template<typename dtype>
79 dtype lcm(const NdArray<dtype>& inArray)
80 {
82
83 return boost::integer::lcm_range(inArray.cbegin(), inArray.cend()).first;
84 }
85#endif // #ifndef NUMCPP_NO_USE_BOOST
86} // namespace nc
87
88#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:135
const_iterator cbegin() const noexcept
Definition NdArrayCore.hpp:1361
const_iterator cend() const noexcept
Definition NdArrayCore.hpp:1669
Definition Cartesian.hpp:39
dtype lcm(dtype inValue1, dtype inValue2) noexcept
Definition lcm.hpp:56