Skip to content

Commit 88360cf

Browse files
committed
tidy up
1 parent 4eace36 commit 88360cf

File tree

2 files changed

+3
-33
lines changed

2 files changed

+3
-33
lines changed

inc/zoo/swar/associative_iteration.h

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ constexpr auto associativeOperatorIterated_regressive(
225225
}
226226

227227

228+
// What I don't understand is why this doesn't work?
228229
template <typename T>
229230
constexpr auto multiply(T a , T b) {
230231
auto operation = [](auto left, auto right, auto count) {
@@ -251,37 +252,6 @@ constexpr auto multiply(T a , T b) {
251252
);
252253
}
253254

254-
// static_assert(multiply(2, 3) == 6);
255-
256-
template <typename T>
257-
constexpr auto expo(T base, T exponent) {
258-
259-
auto operation = [](auto left, auto right, auto counts) {
260-
if (counts) {
261-
return left * right;
262-
} else {
263-
return left;
264-
}
265-
};
266-
267-
auto halver = [](auto counts) {
268-
return counts >> 1;
269-
};
270-
271-
constexpr auto numBits = sizeof(T) * 8;
272-
return associativeOperatorIterated_regressive(
273-
base,
274-
1,
275-
exponent,
276-
meta::BitmaskMaker<T, 1, numBits>().value << 1,
277-
operation,
278-
numBits,
279-
halver
280-
);
281-
}
282-
283-
// static_assert(expo(2, 3) == 8, "expo(2, 3) == 8");
284-
285255
template<int ActualBits, int NB, typename T>
286256
constexpr auto multiplication_OverflowUnsafe_SpecificBitCount(
287257
SWAR<NB, T> multiplicand, SWAR<NB, T> multiplier

test/swar/BasicOperations.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ static_assert(
4242
);
4343

4444
TEST_CASE("Jamie's totally working exponentiation :D") {
45-
constexpr auto base = SWAR<8, u32>{0x02'01'05'06}; // 2 | 1 | 5 | 6
45+
constexpr auto base = SWAR<8, u32>{0x02'00'05'06}; // 2 | 0 | 5 | 6
4646
constexpr auto exponent = SWAR<8, u32>{0x07'00'02'03}; // 7 | 0 | 2 | 3
47-
constexpr auto expected = SWAR<8, u32>{0x80'01'19'D8}; // 128 | 1 | 19 | 216
47+
constexpr auto expected = SWAR<8, u32>{0x80'01'19'D8}; // 128 | 1 | 25 | 216
4848
constexpr auto actual = expo_OverflowUnsafe(base, exponent);
4949
static_assert(expected.value() == actual.value());
5050
CHECK(expected.value() == actual.value());

0 commit comments

Comments
 (0)