NumCpp  2.11.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 
33 #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.)
58  {
60 
61  auto spacedValues = linspace(static_cast<double>(start), static_cast<double>(stop), num, endPoint);
62  stl_algorithms::for_each(spacedValues.begin(),
63  spacedValues.end(),
64  [base](auto& value) -> void { value = utils::powerf(base, value); });
65 
66  return spacedValues;
67  }
68 } // namespace nc
#define STATIC_ASSERT_ARITHMETIC_OR_COMPLEX(dtype)
Definition: StaticAsserts.hpp:56
void for_each(InputIt first, InputIt last, UnaryFunction f)
Definition: StlAlgorithms.hpp:225
Definition: Cartesian.hpp:40
NdArray< dtype > linspace(dtype inStart, dtype inStop, uint32 inNum=50, bool endPoint=true)
Definition: linspace.hpp:60
std::uint32_t uint32
Definition: Types.hpp:40
NdArray< double > logspace(dtype start, dtype stop, uint32 num=50, bool endPoint=true, double base=10.)
Definition: logspace.hpp:57