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
reciprocal.hpp
Go to the documentation of this file.
1
28#pragma once
29
30#include <complex>
31
35#include "NumCpp/Core/Types.hpp"
36#include "NumCpp/NdArray.hpp"
37
38namespace nc
39{
40 //============================================================================
41 // Method Description:
52 template<typename dtype>
54 {
56
58
59 uint32 counter = 0;
60 std::for_each(inArray.cbegin(),
61 inArray.cend(),
62 [&returnArray, &counter](dtype value) noexcept -> void
63 { returnArray[counter++] = 1. / static_cast<double>(value); });
64
65 return returnArray;
66 }
67
68 //============================================================================
69 // Method Description:
80 template<typename dtype>
82 {
84
86
87 uint32 counter = 0;
88 std::for_each(inArray.cbegin(),
89 inArray.cend(),
90 [&returnArray, &counter](std::complex<dtype> value) -> void
91 { returnArray[counter++] = std::complex<double>(1.) / complex_cast<double>(value); });
92
93 return returnArray;
94 }
95} // namespace nc
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition StaticAsserts.hpp:39
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition NdArrayCore.hpp:139
Definition Cartesian.hpp:40
NdArray< dtype > arange(dtype inStart, dtype inStop, dtype inStep=1)
Definition arange.hpp:59
NdArray< double > reciprocal(const NdArray< dtype > &inArray)
Definition reciprocal.hpp:53
std::uint32_t uint32
Definition Types.hpp:40