NumCpp  2.7.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
logspace.hpp
Go to the documentation of this file.
1 #pragma once
29 
30 #include "NumCpp/NdArray.hpp"
34 #include "NumCpp/Utils/powerf.hpp"
35 
36 namespace nc
37 {
38  //============================================================================
39  // Method Description:
56  template<typename dtype>
57  NdArray<double> logspace(dtype start, dtype stop, uint32 num = 50, bool endPoint = true, double base = 10.0)
58  {
60 
61  auto spacedValues = linspace(static_cast<double>(start), static_cast<double>(stop), num, endPoint);
62  stl_algorithms::for_each(spacedValues.begin(), spacedValues.end(),
63  [base](auto& value) -> void
64  {
65  value = utils::powerf(base, value);
66  });
67 
68  return spacedValues;
69  }
70 } // namespace nc
#define STATIC_ASSERT_ARITHMETIC_OR_COMPLEX(dtype)
Definition: StaticAsserts.hpp:50
void for_each(InputIt first, InputIt last, UnaryFunction f)
Definition: StlAlgorithms.hpp:213
Definition: Coordinate.hpp:45
NdArray< double > logspace(dtype start, dtype stop, uint32 num=50, bool endPoint=true, double base=10.0)
Definition: logspace.hpp:57
NdArray< dtype > linspace(dtype inStart, dtype inStop, uint32 inNum=50, bool endPoint=true)
Definition: linspace.hpp:61
std::uint32_t uint32
Definition: Types.hpp:40