NumCpp
2.14.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
Toggle main menu visibility
Main Page
Related Pages
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
z
Functions
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
z
Variables
a
c
d
e
g
h
i
j
m
n
o
p
s
t
v
Typedefs
Enumerations
Data Structures
Data Structures
Data Structure Index
Class Hierarchy
Data Fields
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
a
c
d
e
i
l
m
n
p
r
s
t
v
x
y
z
Typedefs
a
c
d
i
p
r
s
t
v
Enumerations
Related Symbols
Files
File List
Globals
All
Macros
Examples
▼
NumCpp
Release Notes
Installation
Building
Flags
►
Namespaces
►
Data Structures
▼
Files
►
File List
►
Globals
►
Examples
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
Loading...
Searching...
No Matches
reciprocal.hpp
Go to the documentation of this file.
1
28
#pragma once
29
30
#include <complex>
31
32
#include "
NumCpp/Core/Internal/StaticAsserts.hpp
"
33
#include "
NumCpp/Core/Internal/StdComplexOperators.hpp
"
34
#include "
NumCpp/Core/Internal/StlAlgorithms.hpp
"
35
#include "
NumCpp/Core/Types.hpp
"
36
#include "
NumCpp/NdArray.hpp
"
37
38
namespace
nc
39
{
40
//============================================================================
41
// Method Description:
52
template
<
typename
dtype>
53
NdArray<double>
reciprocal
(
const
NdArray<dtype>
&
inArray
)
54
{
55
STATIC_ASSERT_ARITHMETIC
(
dtype
);
56
57
NdArray<double>
returnArray
(
inArray
.shape());
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
}
53
NdArray<double>
reciprocal
(
const
NdArray<dtype>
&
inArray
) {
…
}
67
68
//============================================================================
69
// Method Description:
80
template
<
typename
dtype>
81
NdArray<std::complex<double>
>
reciprocal
(
const
NdArray
<std::complex<dtype>>&
inArray
)
82
{
83
STATIC_ASSERT_ARITHMETIC
(
dtype
);
84
85
NdArray<std::complex<double>
>
returnArray
(
inArray
.shape());
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
}
81
NdArray<std::complex<double>
>
reciprocal
(
const
NdArray
<std::complex<dtype>>&
inArray
) {
…
}
95
}
// namespace nc
NdArray.hpp
StaticAsserts.hpp
STATIC_ASSERT_ARITHMETIC
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition
StaticAsserts.hpp:39
StdComplexOperators.hpp
StlAlgorithms.hpp
Types.hpp
nc::NdArray
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition
NdArrayCore.hpp:139
nc
Definition
Cartesian.hpp:40
nc::arange
NdArray< dtype > arange(dtype inStart, dtype inStop, dtype inStep=1)
Definition
arange.hpp:59
nc::reciprocal
NdArray< double > reciprocal(const NdArray< dtype > &inArray)
Definition
reciprocal.hpp:53
nc::uint32
std::uint32_t uint32
Definition
Types.hpp:40
include
NumCpp
Functions
reciprocal.hpp
Generated by
1.9.8