NumCpp
2.4.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
30
#include "
NumCpp/Core/Internal/StaticAsserts.hpp
"
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:
51
template
<
typename
dtype>
52
NdArray<dtype>
constant1d
(
const
NdArray<dtype>
& inImage,
uint32
inBoundarySize, dtype inConstantValue)
53
{
54
STATIC_ASSERT_ARITHMETIC
(dtype);
55
56
const
uint32
outSize = inImage.
size
() + inBoundarySize * 2;
57
58
NdArray<dtype>
outArray(1, outSize);
59
outArray.
put
(
Slice
(inBoundarySize, inBoundarySize + inImage.
size
()), inImage);
60
61
// left
62
outArray.
put
(
Slice
(0, inBoundarySize), inConstantValue);
63
64
// right
65
outArray.
put
(
Slice
(inImage.
size
() + inBoundarySize, outSize), inConstantValue);
66
67
return
outArray;
68
}
69
}
// namespace boundary
70
}
// namespace filter
71
}
// namespace nc
StaticAsserts.hpp
STATIC_ASSERT_ARITHMETIC
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition:
StaticAsserts.hpp:37
nc::NdArray< dtype >
nc::uint32
std::uint32_t uint32
Definition:
Types.hpp:40
NdArray.hpp
nc::NdArray::put
NdArray< dtype > & put(int32 inIndex, value_type inValue)
Definition:
NdArrayCore.hpp:3729
nc::NdArray::size
size_type size() const noexcept
Definition:
NdArrayCore.hpp:4370
nc
Definition:
Coordinate.hpp:44
nc::filter::boundary::constant1d
NdArray< dtype > constant1d(const NdArray< dtype > &inImage, uint32 inBoundarySize, dtype inConstantValue)
Definition:
constant1d.hpp:52
Types.hpp
nc::Slice
A Class for slicing into NdArrays.
Definition:
Slice.hpp:43
Slice.hpp
include
NumCpp
Filter
Boundaries
Boundaries1d
constant1d.hpp
Generated by
1.8.17