Skip to content

Commit 4801e56

Browse files
committed
tidy
1 parent 88360cf commit 4801e56

File tree

2 files changed

+11
-46
lines changed

2 files changed

+11
-46
lines changed

inc/zoo/swar/associative_iteration.h

Lines changed: 10 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
#ifndef ZOO_SWAR_ASSOCIATIVE_ITERATION_H
22
#define ZOO_SWAR_ASSOCIATIVE_ITERATION_H
33

4-
#include <iostream>
54
#include "zoo/swar/SWAR.h"
65

7-
// include std::cout etc
8-
9-
template<typename ...Args>
10-
void print(Args... args) {
11-
(std::cout << ... << args);
12-
}
13-
146
namespace zoo::swar {
157

168
/// \note This code should be substituted by an application of "progressive" algebraic iteration
@@ -199,26 +191,20 @@ template<
199191
typename CountHalver
200192
>
201193
constexpr auto associativeOperatorIterated_regressive(
202-
const Base base, // 4
203-
const Base neutral, // 1
204-
IterationCount count, // 2
205-
const IterationCount forSquaring, // ??
206-
const Operator op, // plus
207-
unsigned log2Count, // big number
208-
const CountHalver ch // halver
194+
const Base base,
195+
const Base neutral,
196+
IterationCount count,
197+
const IterationCount forSquaring,
198+
const Operator op,
199+
unsigned log2Count,
200+
const CountHalver ch
209201
) {
210-
auto result = neutral; // result = 1
211-
if (!log2Count) { return result; } // still going
202+
auto result = neutral;
203+
if (!log2Count) { return result; }
212204
for (;;) {
213-
result = op(result, base, count); // result = 1 + 4
214-
if constexpr (std::is_same_v<IterationCount, int>) {
215-
print("result1: ", result, "\n");
216-
}
205+
result = op(result, base, count);
217206
if(!--log2Count) { break; }
218207
result = op(result, result, forSquaring);
219-
if constexpr (std::is_same_v<IterationCount, int>) {
220-
print("result2: ", result, "\n");
221-
}
222208
count = ch(count);
223209
}
224210
return result;
@@ -280,27 +266,6 @@ constexpr auto multiplication_OverflowUnsafe_SpecificBitCount(
280266
);
281267
}
282268

283-
284-
/*
285-
// extended from mathematics to generic programming
286-
// see https://github.com/jamierpond/fmtgp/blob/main/2_first_algo/main.cpp
287-
288-
template <typename T> constexpr T exp_acc(T r, T a, T n) {
289-
for (;;) {
290-
if (is_odd(n)) {
291-
r = multiply(r, a);
292-
if (n == 1) {
293-
return r;
294-
}
295-
}
296-
n = half(n);
297-
a = multiply(a, a);
298-
}
299-
}
300-
*/
301-
302-
303-
304269
template<int ActualBits, int NB, typename T>
305270
constexpr auto expo_OverflowUnsafe_SpecificBitCount(
306271
SWAR<NB, T> x,

test/swar/BasicOperations.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ TEST_CASE("Jamie's totally working exponentiation :D") {
5050
CHECK(expected.value() == actual.value());
5151
}
5252

53-
} // namespace Multiplication
53+
}
5454

5555
#define HE(nbits, t, v0, v1) \
5656
static_assert(horizontalEquality<nbits, t>(\

0 commit comments

Comments
 (0)