NumCpp  2.14.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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:
73 {
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
Definition airy_ai.hpp:39
uint32 prime(uint32 n)
Definition prime.hpp:52
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction)
Definition StlAlgorithms.hpp:775
NdArray< dtype > arange(dtype inStart, dtype inStop, dtype inStep=1)
Definition arange.hpp:59
std::uint32_t uint32
Definition Types.hpp:40