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
geomspace.hpp
Go to the documentation of this file.
1
28#pragma once
29
30#include "NumCpp/Core/Enums.hpp"
36#include "NumCpp/NdArray.hpp"
38
39namespace nc
40{
41 //============================================================================
42 // Method Description:
58 template<typename dtype>
60 {
62
63 if (utils::essentiallyEqual(start, dtype{ 0 }))
64 {
65 THROW_INVALID_ARGUMENT_ERROR("Geometric sequence cannot include zero");
66 }
67
68 if (num == 1)
69 {
70 return { static_cast<double>(start) };
71 }
72 else if (num == 2 && endPoint == EndPoint::YES)
73 {
74 return { static_cast<double>(start), static_cast<double>(stop) };
75 }
76
77 const auto base = nth_root(stop / start, num - 1);
78 const auto logStart = logb(start, base);
79 const auto logStop = logb(stop, base);
81 }
82} // namespace nc
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition Error.hpp:37
#define STATIC_ASSERT_ARITHMETIC_OR_COMPLEX(dtype)
Definition StaticAsserts.hpp:56
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition NdArrayCore.hpp:139
bool essentiallyEqual(dtype inValue1, dtype inValue2) noexcept
Definition essentiallyEqual.hpp:49
Definition Cartesian.hpp:40
auto logb(dtype inValue, dtype inBase) noexcept
Definition logb.hpp:49
NdArray< double > geomspace(dtype start, dtype stop, uint32 num=50, EndPoint endPoint=EndPoint::YES)
Definition geomspace.hpp:59
NdArray< dtype > arange(dtype inStart, dtype inStop, dtype inStep=1)
Definition arange.hpp:59
double nth_root(dtype1 inValue, dtype2 inRoot) noexcept
Definition nth_root.hpp:46
std::uint32_t uint32
Definition Types.hpp:40
NdArray< double > logspace(dtype start, dtype stop, uint32 num=50, EndPoint endPoint=EndPoint::YES, double base=10.)
Definition logspace.hpp:59
EndPoint
End Point boolean.
Definition Enums.hpp:74