NumCpp  2.12.1
A Templatized Header Only C++ Implementation of the Python NumPy Library
prime.hpp
Go to the documentation of this file.
1
28#pragma once
29
30#ifndef NUMCPP_NO_USE_BOOST
31
32#include <string>
33
34#include "boost/math/special_functions/prime.hpp"
35
38#include "NumCpp/Core/Types.hpp"
39#include "NumCpp/NdArray.hpp"
40
41namespace nc::special
42{
43 //============================================================================
44 // Method Description:
53 {
54 if (n > boost::math::max_prime)
55 {
56 THROW_INVALID_ARGUMENT_ERROR("input n must be less than or equal to " +
57 std::to_string(boost::math::max_prime));
58 }
59
60 return boost::math::prime(n);
61 }
62
63 //============================================================================
64 // Method Description:
72 inline NdArray<uint32> prime(const NdArray<uint32>& inArray)
73 {
74 NdArray<uint32> returnArray(inArray.shape());
75
77 inArray.cend(),
78 returnArray.begin(),
79 [](uint32 inValue) -> uint32 { return prime(inValue); });
80
81 return returnArray;
82 }
83} // namespace nc::special
84
85#endif // #ifndef NUMCPP_NO_USE_BOOST
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition: Error.hpp:37
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 Shape & shape() const noexcept
Definition: NdArrayCore.hpp:4511
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1673
iterator begin() noexcept
Definition: NdArrayCore.hpp:1315
Definition: airy_ai.hpp:39
uint32 prime(uint32 n)
Definition: prime.hpp:52
NdArray< uint32 > prime(const NdArray< uint32 > &inArray)
Definition: prime.hpp:72
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction)
Definition: StlAlgorithms.hpp:775
std::uint32_t uint32
Definition: Types.hpp:40