NumCpp  2.3.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
gcd.hpp
Go to the documentation of this file.
1 #pragma once
29 
32 #include "NumCpp/NdArray.hpp"
33 
34 #include "boost/integer/common_factor_rt.hpp"
35 
36 namespace nc
37 {
38  //============================================================================
39  // Method Description:
49  template<typename dtype>
50  dtype gcd(dtype inValue1, dtype inValue2) noexcept
51  {
52  STATIC_ASSERT_INTEGER(dtype);
53  return boost::integer::gcd(inValue1, inValue2);
54  }
55 
56  //============================================================================
57  // Method Description:
67  template<typename dtype>
68  dtype gcd(const NdArray<dtype>& inArray)
69  {
70  STATIC_ASSERT_INTEGER(dtype);
71  return boost::integer::gcd_range(inArray.cbegin(), inArray.cend()).first;
72  }
73 } // namespace nc
STATIC_ASSERT_INTEGER
#define STATIC_ASSERT_INTEGER(dtype)
Definition: StaticAsserts.hpp:40
StaticAsserts.hpp
Error.hpp
nc::NdArray< dtype >
nc::gcd
dtype gcd(dtype inValue1, dtype inValue2) noexcept
Definition: gcd.hpp:50
NdArray.hpp
nc::gcd
dtype gcd(const NdArray< dtype > &inArray)
Definition: gcd.hpp:68
nc::NdArray::cend
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1490
nc
Definition: Coordinate.hpp:44
nc::NdArray::cbegin
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1146