Skip to content

Commit e88971d

Browse files
authored
feat: implement iterative hypercomplex multiplication (#52)
1 parent b8c3450 commit e88971d

File tree

12 files changed

+378
-83
lines changed

12 files changed

+378
-83
lines changed

.github/workflows/docs.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
name: docs
22

3-
on:
4-
push:
5-
branches:
6-
- master
3+
on: [push]
74

85
jobs:
96

107
gh-pages:
11-
runs-on: ubuntu-20.04
8+
runs-on: ubuntu-22.04
129
env:
1310
test-directory: .test/docs
1411

.github/workflows/draft-pdf.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on: [push]
55
jobs:
66

77
paper:
8-
runs-on: ubuntu-20.04
8+
runs-on: ubuntu-22.04
99
name: Paper Draft
1010

1111
steps:

.github/workflows/include.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
name: Include
22

3-
on:
4-
push:
5-
branches:
6-
- "*"
7-
pull_request:
8-
branches:
9-
- master
3+
on: [push]
104

115
jobs:
126
Include:
137
runs-on: ${{ matrix.os }}
148
strategy:
159
matrix:
16-
os: [macos-12, ubuntu-20.04]
10+
os: [macos-12, ubuntu-22.04]
1711
env:
1812
working-directory: .test/include
1913

.github/workflows/install.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
name: Install
22

3-
on:
4-
push:
5-
branches:
6-
- "*"
7-
pull_request:
8-
branches:
9-
- master
3+
on: [push]
104

115
jobs:
126
Install:
137
runs-on: ${{ matrix.os }}
148
strategy:
159
matrix:
16-
os: [macos-12, ubuntu-20.04]
10+
os: [macos-12, ubuntu-22.04]
1711
env:
1812
test-directory: .test/install
1913
lib-directory: "hypercomplex"

.github/workflows/lint.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
name: cpplint
22

3-
on:
4-
push:
5-
branches:
6-
- "*"
7-
pull_request:
8-
branches:
9-
- master
3+
on: [push]
104

115
jobs:
126
cpplint:
13-
runs-on: ubuntu-20.04
7+
runs-on: ubuntu-22.04
148

159
steps:
1610

.github/workflows/unit.yml

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
11
name: Catch2
22

3-
on:
4-
push:
5-
branches:
6-
- "*"
7-
pull_request:
8-
branches:
9-
- master
3+
on: [push]
104

115
jobs:
126

137
platform-compatibility:
148
runs-on: ${{ matrix.os }}
159
strategy:
1610
matrix:
17-
os: [macos-12, ubuntu-20.04]
11+
os: [macos-12, ubuntu-22.04]
1812
fail-fast: false
1913
env:
2014
working-directory: .test/unit
@@ -47,10 +41,10 @@ jobs:
4741

4842
- name: Execute Test Program
4943
working-directory: ${{env.working-directory}}
50-
run: ./test ~[local] -d yes -w NoAssertions --use-colour yes --benchmark-samples 100 --benchmark-resamples 100000
44+
run: ./test -d yes -w NoAssertions --use-colour yes --benchmark-samples 100 --benchmark-resamples 100000
5145

5246
code-coverage:
53-
runs-on: ubuntu-20.04
47+
runs-on: ubuntu-22.04
5448
env:
5549
working-directory: .test/unit
5650

@@ -72,15 +66,15 @@ jobs:
7266
run: cp -r ../../hypercomplex hypercomplex
7367

7468
- name: Display compiler version
75-
run: g++ --version
69+
run: clang++ --version
7670

7771
- name: Compile Test Program
7872
working-directory: ${{env.working-directory}}
79-
run: g++ -O0 -fprofile-arcs -ftest-coverage -Wall --std=c++17 --coverage -o test test.cpp -lmpfr -lgmp
73+
run: g++ -O0 -fprofile-arcs -ftest-coverage -fno-elide-constructors -Wall --std=c++17 --coverage -o test test.cpp -lmpfr -lgmp
8074

8175
- name: Execute Test Program
8276
working-directory: ${{env.working-directory}}
83-
run: ./test ~[local]
77+
run: ./test
8478

8579
- name: Generate Coverage Report
8680
working-directory: ${{env.working-directory}}
@@ -98,7 +92,7 @@ jobs:
9892
verbose: true
9993

10094
memcheck:
101-
runs-on: ubuntu-20.04
95+
runs-on: ubuntu-22.04
10296
env:
10397
working-directory: .test/unit
10498

@@ -129,6 +123,6 @@ jobs:
129123
- name: Analyze Test Program Execution
130124
working-directory: ${{env.working-directory}}
131125
run: |
132-
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --log-file=valgrind.txt ./test ~[local]
126+
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --log-file=valgrind.txt ./test ~[benchmark]
133127
cat valgrind.txt
134128
grep -q -w "All heap blocks were freed -- no leaks are possible" "valgrind.txt"

.gitpod.dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ FROM ubuntu:latest
99
# workspace user (`gitpod`) is non-root and won't be able to install
1010
# and use `sudo` to install any other tools in a live workspace.
1111
RUN apt-get update && apt-get install -yq \
12-
git git-lfs sudo g++ make libmpfr-dev \
12+
git git-lfs sudo g++ make valgrind libmpfr-dev python3 python3-pip doxygen \
13+
&& pip install cpplint \
1314
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/*
1415

1516
# Create the gitpod user. UID must be 33333.

.test/docs/test.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ int main(void){
8686
const unsigned int fig1a_MaxDeg = 6; // N = 7
8787
const int64_t fig1a_p = 2;
8888
const int64_t fig1a_q = 1151;
89+
Hypercomplex<Polynomial<fig1a_MaxDeg>, fig1a_dim>::init();
8990
// Public Key
9091
Polynomial<fig1a_MaxDeg> F1a_coefficients[fig1a_dim];
9192
F1a_coefficients[1][0] = 0;
@@ -218,13 +219,15 @@ int main(void){
218219
);
219220
CenteredLift(&M1a, fig1a_p);
220221
assert( D1a == M1a );
222+
Hypercomplex<Polynomial<fig1a_MaxDeg>, fig1a_dim>::clear();
221223
//
222224
// PUBLICATION: QR code
223225
//
224226
const unsigned int fig1b_dim = 32;
225227
const unsigned int fig1b_MaxDeg = 28; // N = 29
226228
const int64_t fig1b_p = 3;
227229
const int64_t fig1b_q = 1723;
230+
Hypercomplex<Polynomial<fig1b_MaxDeg>, fig1b_dim>::init();
228231
// Public Key
229232
Polynomial<fig1b_MaxDeg> F1b_coefficients[fig1b_dim];
230233
F1b_coefficients[1][0] = 1;
@@ -311,13 +314,15 @@ int main(void){
311314
);
312315
CenteredLift(&M1b, fig1b_p);
313316
assert( D1b == M1b );
317+
Hypercomplex<Polynomial<fig1b_MaxDeg>, fig1b_dim>::clear();
314318
//
315319
// PUBLICATION: MEME
316320
//
317321
const unsigned int fig1c_dim = 128;
318322
const unsigned int fig1c_MaxDeg = 126; // N = 127
319323
const int64_t fig1c_p = 17;
320324
const int64_t fig1c_q = 16777213;
325+
Hypercomplex<Polynomial<fig1c_MaxDeg>, fig1c_dim>::init();
321326
// Public Key
322327
Polynomial<fig1c_MaxDeg> F1c_coefficients[fig1c_dim];
323328
F1c_coefficients[1][0] = 1;
@@ -350,7 +355,6 @@ int main(void){
350355
F1c, G1c, fig1c_q
351356
);
352357
// Encryption
353-
int64_t nyanarr[fig1c_dim][fig1c_MaxDeg+1];
354358
Polynomial<fig1c_MaxDeg> M1c_coefficients[fig1c_dim];
355359
std::ifstream inputfile("nyan.txt");
356360
for (unsigned int i=0; i < fig1c_dim; i++) {
@@ -381,6 +385,7 @@ int main(void){
381385
);
382386
CenteredLift(&M1c, fig1c_p);
383387
assert( D1c == M1c );
388+
Hypercomplex<Polynomial<fig1c_MaxDeg>, fig1c_dim>::clear();
384389
//
385390
return 0;
386391
}

0 commit comments

Comments
 (0)