forked from microsoft/SEAL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
examples.cpp
105 lines (90 loc) · 3.36 KB
/
examples.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
#include "examples.h"
using namespace std;
using namespace seal;
int main()
{
cout << "Microsoft SEAL version: " << SEAL_VERSION << endl;
while (true)
{
cout << "+---------------------------------------------------------+" << endl;
cout << "| The following examples should be executed while reading |" << endl;
cout << "| comments in associated files in native/examples/. |" << endl;
cout << "+---------------------------------------------------------+" << endl;
cout << "| Examples | Source Files |" << endl;
cout << "+----------------------------+----------------------------+" << endl;
cout << "| 1. BFV Basics | 1_bfv_basics.cpp |" << endl;
cout << "| 2. Encoders | 2_encoders.cpp |" << endl;
cout << "| 3. Levels | 3_levels.cpp |" << endl;
cout << "| 4. BGV Basics | 4_bgv_basics.cpp |" << endl;
cout << "| 5. CKKS Basics | 5_ckks_basics.cpp |" << endl;
cout << "| 6. Rotation | 6_rotation.cpp |" << endl;
cout << "| 7. Serialization | 7_serialization.cpp |" << endl;
cout << "| 8. Performance Test | 8_performance.cpp |" << endl;
cout << "+----------------------------+----------------------------+" << endl;
/*
Print how much memory we have allocated from the current memory pool.
By default the memory pool will be a static global pool and the
MemoryManager class can be used to change it. Most users should have
little or no reason to touch the memory allocation system.
*/
size_t megabytes = MemoryManager::GetPool().alloc_byte_count() >> 20;
cout << "[" << setw(7) << right << megabytes << " MB] "
<< "Total allocation from the memory pool" << endl;
int selection = 0;
bool valid = true;
do
{
cout << endl << "> Run example (1 ~ 8) or exit (0): ";
if (!(cin >> selection))
{
valid = false;
}
else if (selection < 0 || selection > 8)
{
valid = false;
}
else
{
valid = true;
}
if (!valid)
{
cout << " [Beep~~] valid option: type 0 ~ 8" << endl;
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
} while (!valid);
switch (selection)
{
case 1:
example_bfv_basics();
break;
case 2:
example_encoders();
break;
case 3:
example_levels();
break;
case 4:
example_bgv_basics();
break;
case 5:
example_ckks_basics();
break;
case 6:
example_rotation();
break;
case 7:
example_serialization();
break;
case 8:
example_performance_test();
break;
case 0:
return 0;
}
}
return 0;
}