NumCpp  2.1.0
A C++ implementation of the Python Numpy library
signbit.hpp
Go to the documentation of this file.
1 #pragma once
30 
33 #include "NumCpp/NdArray.hpp"
34 
35 namespace nc
36 {
37  //============================================================================
38  // Method Description:
48  template<typename dtype>
49  bool signbit(dtype inValue) noexcept
50  {
52 
53  return inValue < dtype{ 0 } ? true : false;
54  }
55 
56  //============================================================================
57  // Method Description:
67  template<typename dtype>
69  {
70  NdArray<bool> returnArray(inArray.shape());
71  stl_algorithms::transform(inArray.cbegin(), inArray.cend(), returnArray.begin(),
72  [](dtype inValue) noexcept -> bool
73  {
74  return signbit(inValue);
75  });
76 
77  return returnArray;
78  }
79 } // namespace nc
StaticAsserts.hpp
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
Definition: Coordinate.hpp:45
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::signbit
bool signbit(dtype inValue) noexcept
Definition: signbit.hpp:49