NumCpp  1.0
A C++ implementation of the Python Numpy library
unique.hpp
Go to the documentation of this file.
1 #pragma once
30 
31 #include "NumCpp/NdArray.hpp"
36 
37 #include <complex>
38 #include <vector>
39 
40 namespace nc
41 {
42  //============================================================================
43  // Method Description:
56  template<typename dtype>
58  {
60 
61  const auto comp = [](const dtype lhs, const dtype rhs) noexcept -> bool
62  {
63  return utils::essentiallyEqual(lhs, rhs);
64  };
65 
66  const auto sorted = sort(inArray);
67 
68  std::vector<dtype> res(sorted.size());
69  const auto last = stl_algorithms::unique_copy(sorted.begin(), sorted.end(), res.begin(), comp);
70 
71  return NdArray<dtype>(res.begin(), last);
72  }
73 }
StaticAsserts.hpp
nc::utils::essentiallyEqual
bool essentiallyEqual(dtype inValue1, dtype inValue2) noexcept
Definition: essentiallyEqual.hpp:53
STATIC_ASSERT_ARITHMETIC_OR_COMPLEX
#define STATIC_ASSERT_ARITHMETIC_OR_COMPLEX(dtype)
Definition: StaticAsserts.hpp:51
nc::NdArray< dtype >
NdArray.hpp
nc::unique
NdArray< dtype > unique(const NdArray< dtype > &inArray)
Definition: unique.hpp:57
nc
Definition: Coordinate.hpp:45
essentiallyEqual.hpp
nc::stl_algorithms::unique_copy
constexpr OutputIt unique_copy(InputIt first, InputIt last, OutputIt destination) noexcept
Definition: StlAlgorithms.hpp:745
StlAlgorithms.hpp
sort.hpp
nc::sort
NdArray< dtype > sort(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition: sort.hpp:48