NumCpp  2.5.1
A Templatized Header Only C++ Implementation of the Python NumPy Library
nearest1d.hpp
Go to the documentation of this file.
1 #pragma once
29 
31 #include "NumCpp/Core/Slice.hpp"
32 #include "NumCpp/NdArray.hpp"
33 
34 namespace nc
35 {
36  namespace filter
37  {
38  namespace boundary
39  {
40  //============================================================================
41  // Method Description:
49  template<typename dtype>
50  NdArray<dtype> nearest1d(const NdArray<dtype>& inImage, uint32 inBoundarySize)
51  {
53 
54  const uint32 outSize = inImage.size() + inBoundarySize * 2;
55 
56  NdArray<dtype> outArray(1, outSize);
57  outArray.put(Slice(inBoundarySize, inBoundarySize + inImage.size()), inImage);
58 
59  // left
60  outArray.put(Slice(0, inBoundarySize), inImage.front());
61 
62  // right
63  outArray.put(Slice(inImage.size() + inBoundarySize, outSize), inImage.back());
64 
65  return outArray;
66  }
67  } // namespace boundary
68  } // namespace filter
69 } // namespace nc
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:37
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:72
NdArray< dtype > & put(int32 inIndex, value_type inValue)
Definition: NdArrayCore.hpp:3856
size_type size() const noexcept
Definition: NdArrayCore.hpp:4497
const_reference back() const noexcept
Definition: NdArrayCore.hpp:2344
const_reference front() const noexcept
Definition: NdArrayCore.hpp:2933
A Class for slicing into NdArrays.
Definition: Slice.hpp:44
NdArray< dtype > nearest1d(const NdArray< dtype > &inImage, uint32 inBoundarySize)
Definition: nearest1d.hpp:50
Definition: Coordinate.hpp:45
std::uint32_t uint32
Definition: Types.hpp:40