NumCpp  2.9.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
constant1d.hpp
Go to the documentation of this file.
1 #pragma once
29 
31 #include "NumCpp/Core/Slice.hpp"
32 #include "NumCpp/Core/Types.hpp"
33 #include "NumCpp/NdArray.hpp"
34 
35 namespace nc
36 {
37  namespace filter
38  {
39  namespace boundary
40  {
41  //============================================================================
42  // Method Description:
50  template<typename dtype>
51  NdArray<dtype> constant1d(const NdArray<dtype>& inImage, uint32 inBoundarySize, dtype inConstantValue)
52  {
54 
55  const uint32 outSize = inImage.size() + inBoundarySize * 2;
56 
57  NdArray<dtype> outArray(1, outSize);
58  outArray.put(Slice(inBoundarySize, inBoundarySize + inImage.size()), inImage);
59 
60  // left
61  outArray.put(Slice(0, inBoundarySize), inConstantValue);
62 
63  // right
64  outArray.put(Slice(inImage.size() + inBoundarySize, outSize), inConstantValue);
65 
66  return outArray;
67  }
68  } // namespace boundary
69  } // namespace filter
70 } // 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:3479
size_type size() const noexcept
Definition: NdArrayCore.hpp:4105
A Class for slicing into NdArrays.
Definition: Slice.hpp:44
NdArray< dtype > constant1d(const NdArray< dtype > &inImage, uint32 inBoundarySize, dtype inConstantValue)
Definition: constant1d.hpp:51
Definition: Coordinate.hpp:45
std::uint32_t uint32
Definition: Types.hpp:40