NumCpp  2.1.0
A C++ implementation of the Python Numpy library
isnan.hpp
Go to the documentation of this file.
1 #pragma once
30 
33 #include "NumCpp/NdArray.hpp"
34 
35 #include <cmath>
36 
37 namespace nc
38 {
39  //============================================================================
40  // Method Description:
51  template<typename dtype>
52  bool isnan(dtype inValue) noexcept
53  {
55 
57  {
58  return false;
59  }
60 
61  return std::isnan(static_cast<double>(inValue)); // static_cast is needed for compiler error
62  }
63 
64  //============================================================================
65  // Method Description:
76  template<typename dtype>
78  {
79  NdArray<bool> returnArray(inArray.shape());
80  stl_algorithms::transform(inArray.cbegin(), inArray.cend(), returnArray.begin(),
81  [](dtype inValue) noexcept -> bool
82  {
83  return isnan(inValue);
84  });
85 
86  return returnArray;
87  }
88 } // namespace nc
nc::NdArray::shape
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4312
STATIC_ASSERT_ARITHMETIC
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:38
nc::NdArray< bool >
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::isnan
NdArray< bool > isnan(const NdArray< dtype > &inArray)
Definition: isnan.hpp:77
nc
Definition: Coordinate.hpp:45
nc::DtypeInfo
Holds info about the dtype.
Definition: DtypeInfo.hpp:41
DtypeInfo.hpp
nc::NdArray::cbegin
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1147
StlAlgorithms.hpp
nc::NdArray::begin
iterator begin() noexcept
Definition: NdArrayCore.hpp:1091
nc::isnan
bool isnan(dtype inValue) noexcept
Definition: isnan.hpp:52