NumCpp  2.1.0
A C++ implementation of the Python Numpy library
log.hpp
Go to the documentation of this file.
1 #pragma once
30 
33 #include "NumCpp/NdArray.hpp"
34 
35 #include <cmath>
36 #include <complex>
37 
38 namespace nc
39 {
40  //============================================================================
41  // Method Description:
52  template<typename dtype>
53  auto log(dtype inValue) noexcept
54  {
56 
57  return std::log(inValue);
58  }
59 
60  //============================================================================
61  // Method Description:
72  template<typename dtype>
73  auto log(const NdArray<dtype>& inArray)
74  {
75  NdArray<decltype(log(dtype{0}))> returnArray(inArray.shape());
76  stl_algorithms::transform(inArray.cbegin(), inArray.cend(), returnArray.begin(),
77  [](dtype inValue) noexcept -> auto
78  {
79  return log(inValue);
80  });
81 
82  return returnArray;
83  }
84 } // namespace nc
StaticAsserts.hpp
nc::NdArray::shape
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4312
nc::log
auto log(const NdArray< dtype > &inArray)
Definition: log.hpp:73
STATIC_ASSERT_ARITHMETIC_OR_COMPLEX
#define STATIC_ASSERT_ARITHMETIC_OR_COMPLEX(dtype)
Definition: StaticAsserts.hpp:51
nc::NdArray< dtype >
nc::stl_algorithms::transform
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction)
Definition: StlAlgorithms.hpp:703
NdArray.hpp
nc::NdArray::cend
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1491
nc
Definition: Coordinate.hpp:45
nc::log
auto log(dtype inValue) noexcept
Definition: log.hpp:53
nc::NdArray::cbegin
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1147
StlAlgorithms.hpp
nc::NdArray::begin
iterator begin() noexcept
Definition: NdArrayCore.hpp:1091