Skip to content

Commit 78be7f7

Browse files
committed
update name
1 parent 582affe commit 78be7f7

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

inc/zoo/swar/associative_iteration.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,21 +223,24 @@ constexpr auto multiply(T a , T b) {
223223
};
224224

225225
auto halver = [](auto count) {
226-
return count >> 1;
226+
return count << 1;
227227
};
228228

229229
constexpr auto numBits = sizeof(T) * 8;
230+
constexpr auto msb = 1 << (numBits - 1);
230231
return associativeOperatorIterated_regressive(
231232
a, // base
232233
0, // neutral
233234
b, // count
234-
1, // forSquaring, pretty sure this is where i am not understanding
235+
0, // forSquaring, pretty sure this is where i am not understanding
235236
operation, // operation
236237
numBits, // log2Count
237238
halver // halver
238239
);
239240
}
240241

242+
// static_assert(multiply(3, 4) == 12, "multiply failed");
243+
241244
template<int ActualBits, int NB, typename T>
242245
constexpr auto multiplication_OverflowUnsafe_SpecificBitCount(
243246
SWAR<NB, T> multiplicand, SWAR<NB, T> multiplier
@@ -267,7 +270,7 @@ constexpr auto multiplication_OverflowUnsafe_SpecificBitCount(
267270
}
268271

269272
template<int ActualBits, int NB, typename T>
270-
constexpr auto expo_OverflowUnsafe_SpecificBitCount(
273+
constexpr auto exponentiation_OverflowUnsafe_SpecificBitCount(
271274
SWAR<NB, T> x,
272275
SWAR<NB, T> exponent
273276
) {
@@ -339,12 +342,12 @@ constexpr auto multiplication_OverflowUnsafe(
339342
}
340343

341344
template<int NB, typename T>
342-
constexpr auto expo_OverflowUnsafe(
345+
constexpr auto exponentiation_OverflowUnsafe(
343346
SWAR<NB, T> base,
344347
SWAR<NB, T> exponent
345348
) {
346349
return
347-
expo_OverflowUnsafe_SpecificBitCount<NB>(
350+
exponentiation_OverflowUnsafe_SpecificBitCount<NB>(
348351
base, exponent
349352
);
350353
}

test/swar/BasicOperations.cpp

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

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

0 commit comments

Comments
 (0)