47 template<
typename dtype, std::enable_if_t<std::is_
integral_v<dtype> || std::is_same_v<dtype,
bool>,
int> = 0>
54 const auto numFullValues = a.
size() / 8;
55 const auto leftOvers = a.
size() % 8;
56 const auto resultSize = leftOvers == 0 ? numFullValues : numFullValues + 1;
63 const auto startIdx = i * 8;
64 for (
auto bit = 0; bit < 8; ++bit)
66 auto value =
static_cast<uint8>(a[startIdx + bit]);
67 value = value == 0 ? 0 : 1;
68 result[i] |= (value << bit);
74 const auto startIdx = numFullValues * 8;
75 for (std::remove_const_t<
decltype(leftOvers)> bit = 0; bit < leftOvers; ++bit)
77 auto value =
static_cast<uint8>(a[startIdx + bit]);
78 value = value == 0 ? 0 : 1;
79 result.
back() |= (value << bit);
87 const auto aShape = a.
shape();
88 const auto numFullValues = aShape.
cols / 8;
89 const auto leftOvers = aShape.cols % 8;
90 const auto resultSize = leftOvers == 0 ? numFullValues : numFullValues + 1;
93 const auto resultCSlice = result.
cSlice();
94 const auto aCSlice = a.
cSlice();
125 template<
typename dtype, std::enable_if_t<std::is_
integral_v<dtype> || std::is_same_v<dtype,
bool>,
int> = 0>
132 const auto numFullValues = a.
size() / 8;
133 const auto leftOvers = a.
size() % 8;
134 const auto resultSize = leftOvers == 0 ? numFullValues : numFullValues + 1;
141 const auto startIdx = i * 8;
142 for (
auto bit = 0; bit < 8; ++bit)
144 auto value =
static_cast<uint8>(a[startIdx + bit]);
145 value = value == 0 ? 0 : 1;
146 result[i] |= (value << (7 - bit));
152 const auto startIdx = numFullValues * 8;
153 for (std::remove_const_t<
decltype(leftOvers)> bit = 0; bit < leftOvers; ++bit)
155 auto value =
static_cast<uint8>(a[startIdx + bit]);
156 value = value == 0 ? 0 : 1;
157 result.
back() |= (value << (7 - bit));
165 const auto aShape = a.
shape();
166 const auto numFullValues = aShape.
cols / 8;
167 const auto leftOvers = aShape.cols % 8;
168 const auto resultSize = leftOvers == 0 ? numFullValues : numFullValues + 1;
171 const auto resultCSlice = result.
cSlice();
172 const auto aCSlice = a.
cSlice();
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition: Error.hpp:37
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:139
size_type size() const noexcept
Definition: NdArrayCore.hpp:4524
self_type transpose() const
Definition: NdArrayCore.hpp:4882
const Shape & shape() const noexcept
Definition: NdArrayCore.hpp:4511
self_type & fill(value_type inFillValue) noexcept
Definition: NdArrayCore.hpp:2808
const_reference back() const noexcept
Definition: NdArrayCore.hpp:2287
uint32 size_type
Definition: NdArrayCore.hpp:156
Slice cSlice(index_type inStartIdx=0, size_type inStepSize=1) const
Definition: NdArrayCore.hpp:1008
self_type & put(index_type inIndex, const value_type &inValue)
Definition: NdArrayCore.hpp:3693
uint32 cols
Definition: Core/Shape.hpp:45
Definition: Cartesian.hpp:40
NdArray< uint8 > packbitsBigEndian(const NdArray< dtype > &a, Axis axis=Axis::NONE)
Definition: packbits.hpp:126
Axis
Enum To describe an axis.
Definition: Enums.hpp:36
NdArray< uint8 > packbitsLittleEndian(const NdArray< dtype > &a, Axis axis=Axis::NONE)
Definition: packbits.hpp:48
std::uint8_t uint8
Definition: Types.hpp:42