NumCpp  2.1.0
A C++ implementation of the Python Numpy library
square.hpp
Go to the documentation of this file.
1 #pragma once
30 
33 #include "NumCpp/NdArray.hpp"
34 #include "NumCpp/Utils/sqr.hpp"
35 
36 namespace nc
37 {
38  //============================================================================
39  // Method Description:
49  template<typename dtype>
50  constexpr dtype square(dtype inValue) noexcept
51  {
53 
54  return utils::sqr(inValue);
55  }
56 
57  //============================================================================
58  // Method Description:
68  template<typename dtype>
70  {
71  NdArray<dtype> returnArray(inArray.shape());
72  stl_algorithms::transform(inArray.cbegin(), inArray.cend(), returnArray.begin(),
73  [](dtype inValue) noexcept -> dtype
74  {
75  return square(inValue);
76  });
77 
78  return returnArray;
79  }
80 } // namespace nc
StaticAsserts.hpp
nc::NdArray::shape
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4312
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
sqr.hpp
nc::NdArray::cbegin
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1147
nc::utils::sqr
constexpr dtype sqr(dtype inValue) noexcept
Definition: sqr.hpp:45
StlAlgorithms.hpp
nc::square
constexpr dtype square(dtype inValue) noexcept
Definition: square.hpp:50
nc::NdArray::begin
iterator begin() noexcept
Definition: NdArrayCore.hpp:1091