Bitcoin Core 28.99.0
P2P Digital Currency
generic_1byte.cpp
Go to the documentation of this file.
1/**********************************************************************
2 * Copyright (c) 2018 Pieter Wuille, Greg Maxwell, Gleb Naumenko *
3 * Distributed under the MIT software license, see the accompanying *
4 * file LICENSE or http://www.opensource.org/licenses/mit-license.php.*
5 **********************************************************************/
6
7/* This file was substantially auto-generated by doc/gen_params.sage. */
8#include "../fielddefines.h"
9
10#if defined(ENABLE_FIELD_BYTES_INT_1)
11
12#include "generic_common_impl.h"
13
14#include "../lintrans.h"
15#include "../sketch_impl.h"
16
17#endif
18
19#include "../sketch.h"
20
21namespace {
22#ifdef ENABLE_FIELD_INT_2
23// 2 bit field
24typedef RecLinTrans<uint8_t, 2> StatTable2;
25typedef RecLinTrans<uint8_t, 2> DynTable2;
26constexpr StatTable2 SQR_TABLE_2({0x1, 0x3});
27constexpr StatTable2 QRT_TABLE_2({0x2, 0});
28typedef Field<uint8_t, 2, 3, StatTable2, DynTable2, &SQR_TABLE_2, &QRT_TABLE_2> Field2;
29#endif
30
31#ifdef ENABLE_FIELD_INT_3
32// 3 bit field
33typedef RecLinTrans<uint8_t, 3> StatTable3;
34typedef RecLinTrans<uint8_t, 3> DynTable3;
35constexpr StatTable3 SQR_TABLE_3({0x1, 0x4, 0x6});
36constexpr StatTable3 QRT_TABLE_3({0, 0x4, 0x6});
37typedef Field<uint8_t, 3, 3, StatTable3, DynTable3, &SQR_TABLE_3, &QRT_TABLE_3> Field3;
38#endif
39
40#ifdef ENABLE_FIELD_INT_4
41// 4 bit field
42typedef RecLinTrans<uint8_t, 4> StatTable4;
43typedef RecLinTrans<uint8_t, 4> DynTable4;
44constexpr StatTable4 SQR_TABLE_4({0x1, 0x4, 0x3, 0xc});
45constexpr StatTable4 QRT_TABLE_4({0x6, 0xa, 0x8, 0});
46typedef Field<uint8_t, 4, 3, StatTable4, DynTable4, &SQR_TABLE_4, &QRT_TABLE_4> Field4;
47#endif
48
49#ifdef ENABLE_FIELD_INT_5
50// 5 bit field
51typedef RecLinTrans<uint8_t, 5> StatTable5;
52typedef RecLinTrans<uint8_t, 3, 2> DynTable5;
53constexpr StatTable5 SQR_TABLE_5({0x1, 0x4, 0x10, 0xa, 0xd});
54constexpr StatTable5 QRT_TABLE_5({0x14, 0x8, 0xa, 0, 0xe});
55typedef Field<uint8_t, 5, 5, StatTable5, DynTable5, &SQR_TABLE_5, &QRT_TABLE_5> Field5;
56#endif
57
58#ifdef ENABLE_FIELD_INT_6
59// 6 bit field
60typedef RecLinTrans<uint8_t, 6> StatTable6;
61typedef RecLinTrans<uint8_t, 3, 3> DynTable6;
62constexpr StatTable6 SQR_TABLE_6({0x1, 0x4, 0x10, 0x3, 0xc, 0x30});
63constexpr StatTable6 QRT_TABLE_6({0x3a, 0x26, 0x24, 0x14, 0x20, 0});
64typedef Field<uint8_t, 6, 3, StatTable6, DynTable6, &SQR_TABLE_6, &QRT_TABLE_6> Field6;
65#endif
66
67#ifdef ENABLE_FIELD_INT_7
68// 7 bit field
69typedef RecLinTrans<uint8_t, 4, 3> StatTable7;
70typedef RecLinTrans<uint8_t, 4, 3> DynTable7;
71constexpr StatTable7 SQR_TABLE_7({0x1, 0x4, 0x10, 0x40, 0x6, 0x18, 0x60});
72constexpr StatTable7 QRT_TABLE_7({0, 0x14, 0x16, 0x72, 0x12, 0x40, 0x7a});
73typedef Field<uint8_t, 7, 3, StatTable7, DynTable7, &SQR_TABLE_7, &QRT_TABLE_7> Field7;
74#endif
75
76#ifdef ENABLE_FIELD_INT_8
77// 8 bit field
78typedef RecLinTrans<uint8_t, 4, 4> StatTable8;
79typedef RecLinTrans<uint8_t, 4, 4> DynTable8;
80constexpr StatTable8 SQR_TABLE_8({0x1, 0x4, 0x10, 0x40, 0x1b, 0x6c, 0xab, 0x9a});
81constexpr StatTable8 QRT_TABLE_8({0xbc, 0x2a, 0x28, 0x86, 0x2c, 0xde, 0x8e, 0});
82typedef Field<uint8_t, 8, 27, StatTable8, DynTable8, &SQR_TABLE_8, &QRT_TABLE_8> Field8;
83#endif
84}
85
86Sketch* ConstructGeneric1Byte(int bits, int implementation)
87{
88 switch (bits) {
89#ifdef ENABLE_FIELD_INT_2
90 case 2: return new SketchImpl<Field2>(implementation, 2);
91#endif
92#ifdef ENABLE_FIELD_INT_3
93 case 3: return new SketchImpl<Field3>(implementation, 3);
94#endif
95#ifdef ENABLE_FIELD_INT_4
96 case 4: return new SketchImpl<Field4>(implementation, 4);
97#endif
98#ifdef ENABLE_FIELD_INT_5
99 case 5: return new SketchImpl<Field5>(implementation, 5);
100#endif
101#ifdef ENABLE_FIELD_INT_6
102 case 6: return new SketchImpl<Field6>(implementation, 6);
103#endif
104#ifdef ENABLE_FIELD_INT_7
105 case 7: return new SketchImpl<Field7>(implementation, 7);
106#endif
107#ifdef ENABLE_FIELD_INT_8
108 case 8: return new SketchImpl<Field8>(implementation, 8);
109#endif
110 default: return nullptr;
111 }
112}
A linear transformation constructed using LinTrans tables for sections of bits.
Definition: lintrans.h:107
Abstract class for internal representation of a minisketch object.
Definition: sketch.h:15
Sketch * ConstructGeneric1Byte(int bits, int implementation)