NumCpp  2.1.0
A C++ implementation of the Python Numpy library
gcd.hpp
Go to the documentation of this file.
1 #pragma once
30 
33 #include "NumCpp/NdArray.hpp"
34 
35 #include "boost/integer/common_factor_rt.hpp"
36 
37 namespace nc
38 {
39  //============================================================================
40  // Method Description:
50  template<typename dtype>
51  dtype gcd(dtype inValue1, dtype inValue2) noexcept
52  {
53  STATIC_ASSERT_INTEGER(dtype);
54  return boost::integer::gcd(inValue1, inValue2);
55  }
56 
57  //============================================================================
58  // Method Description:
68  template<typename dtype>
69  dtype gcd(const NdArray<dtype>& inArray)
70  {
71  STATIC_ASSERT_INTEGER(dtype);
72  return boost::integer::gcd_range(inArray.cbegin(), inArray.cend()).first;
73  }
74 } // namespace nc
STATIC_ASSERT_INTEGER
#define STATIC_ASSERT_INTEGER(dtype)
Definition: StaticAsserts.hpp:41
StaticAsserts.hpp
Error.hpp
nc::NdArray< dtype >
nc::gcd
dtype gcd(dtype inValue1, dtype inValue2) noexcept
Definition: gcd.hpp:51
NdArray.hpp
nc::gcd
dtype gcd(const NdArray< dtype > &inArray)
Definition: gcd.hpp:69
nc::NdArray::cend
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1491
nc
Definition: Coordinate.hpp:45
nc::NdArray::cbegin
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1147