NumCpp  1.0
A C++ implementation of the Python Numpy library
constant1d.hpp
Go to the documentation of this file.
1 #pragma once
30 
31 #include "NumCpp/NdArray.hpp"
32 #include "NumCpp/Core/Slice.hpp"
33 #include "NumCpp/Core/Types.hpp"
35 
36 namespace nc
37 {
38  namespace filter
39  {
40  namespace boundary
41  {
42  //============================================================================
43  // Method Description:
52  template<typename dtype>
53  NdArray<dtype> constant1d(const NdArray<dtype>& inImage, uint32 inBoundarySize, dtype inConstantValue)
54  {
56 
57  const uint32 outSize = inImage.size() + inBoundarySize * 2;
58 
59  NdArray<dtype> outArray(1, outSize);
60  outArray.put(Slice(inBoundarySize, inBoundarySize + inImage.size()), inImage);
61 
62  // left
63  outArray.put(Slice(0, inBoundarySize), inConstantValue);
64 
65  // right
66  outArray.put(Slice(inImage.size() + inBoundarySize, outSize), inConstantValue);
67 
68  return outArray;
69  }
70  }
71  }
72 }
StaticAsserts.hpp
STATIC_ASSERT_ARITHMETIC
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:38
nc::NdArray< dtype >
nc::uint32
std::uint32_t uint32
Definition: Types.hpp:41
NdArray.hpp
nc::NdArray::put
NdArray< dtype > & put(int32 inIndex, value_type inValue)
Definition: NdArrayCore.hpp:3667
nc::NdArray::size
size_type size() const noexcept
Definition: NdArrayCore.hpp:4310
nc
Definition: Coordinate.hpp:45
nc::filter::boundary::constant1d
NdArray< dtype > constant1d(const NdArray< dtype > &inImage, uint32 inBoundarySize, dtype inConstantValue)
Definition: constant1d.hpp:53
Types.hpp
nc::Slice
A Class for slicing into NdArrays.
Definition: Slice.hpp:44
Slice.hpp