NumCpp  2.18.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
Loading...
Searching...
No Matches
var.hpp
Go to the documentation of this file.
1
28#pragma once
29
30#include <complex>
31
34#include "NumCpp/NdArray.hpp"
35
36namespace nc
37{
38 //============================================================================
39 // Method Description:
49 template<typename dtype>
51 {
53
54 NdArray<double> stdValues = stdev(inArray, inAxis);
55 const auto function = [](double& value) -> void { value *= value; };
56
57 stl_algorithms::for_each(stdValues.begin(), stdValues.end(), function);
58 return stdValues;
59 }
60
61 //============================================================================
62 // Method Description:
72 template<typename dtype>
73 NdArray<std::complex<double>> var(const NdArray<std::complex<dtype>>& inArray, Axis inAxis = Axis::NONE)
74 {
76
77 NdArray<std::complex<double>> stdValues = stdev(inArray, inAxis);
78 const auto function = [](std::complex<double>& value) -> void { value *= value; };
79
80 stl_algorithms::for_each(stdValues.begin(), stdValues.end(), function);
81 return stdValues;
82 }
83} // 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:135
iterator end() noexcept
Definition NdArrayCore.hpp:1619
iterator begin() noexcept
Definition NdArrayCore.hpp:1311
void for_each(InputIt first, InputIt last, UnaryFunction f)
Definition StlAlgorithms.hpp:226
Definition Cartesian.hpp:39
NdArray< double > stdev(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition stdev.hpp:52
Axis
Enum To describe an axis.
Definition Enums.hpp:36
@ NONE
Definition Enums.hpp:37
NdArray< double > var(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition var.hpp:50