Bitcoin Core  27.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 
21 namespace {
22 #ifdef ENABLE_FIELD_INT_2
23 // 2 bit field
24 typedef RecLinTrans<uint8_t, 2> StatTable2;
25 typedef RecLinTrans<uint8_t, 2> DynTable2;
26 constexpr StatTable2 SQR_TABLE_2({0x1, 0x3});
27 constexpr StatTable2 QRT_TABLE_2({0x2, 0});
28 typedef 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
33 typedef RecLinTrans<uint8_t, 3> StatTable3;
34 typedef RecLinTrans<uint8_t, 3> DynTable3;
35 constexpr StatTable3 SQR_TABLE_3({0x1, 0x4, 0x6});
36 constexpr StatTable3 QRT_TABLE_3({0, 0x4, 0x6});
37 typedef 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
42 typedef RecLinTrans<uint8_t, 4> StatTable4;
43 typedef RecLinTrans<uint8_t, 4> DynTable4;
44 constexpr StatTable4 SQR_TABLE_4({0x1, 0x4, 0x3, 0xc});
45 constexpr StatTable4 QRT_TABLE_4({0x6, 0xa, 0x8, 0});
46 typedef 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
51 typedef RecLinTrans<uint8_t, 5> StatTable5;
52 typedef RecLinTrans<uint8_t, 3, 2> DynTable5;
53 constexpr StatTable5 SQR_TABLE_5({0x1, 0x4, 0x10, 0xa, 0xd});
54 constexpr StatTable5 QRT_TABLE_5({0x14, 0x8, 0xa, 0, 0xe});
55 typedef 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
60 typedef RecLinTrans<uint8_t, 6> StatTable6;
61 typedef RecLinTrans<uint8_t, 3, 3> DynTable6;
62 constexpr StatTable6 SQR_TABLE_6({0x1, 0x4, 0x10, 0x3, 0xc, 0x30});
63 constexpr StatTable6 QRT_TABLE_6({0x3a, 0x26, 0x24, 0x14, 0x20, 0});
64 typedef 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
69 typedef RecLinTrans<uint8_t, 4, 3> StatTable7;
70 typedef RecLinTrans<uint8_t, 4, 3> DynTable7;
71 constexpr StatTable7 SQR_TABLE_7({0x1, 0x4, 0x10, 0x40, 0x6, 0x18, 0x60});
72 constexpr StatTable7 QRT_TABLE_7({0, 0x14, 0x16, 0x72, 0x12, 0x40, 0x7a});
73 typedef 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
78 typedef RecLinTrans<uint8_t, 4, 4> StatTable8;
79 typedef RecLinTrans<uint8_t, 4, 4> DynTable8;
80 constexpr StatTable8 SQR_TABLE_8({0x1, 0x4, 0x10, 0x40, 0x1b, 0x6c, 0xab, 0x9a});
81 constexpr StatTable8 QRT_TABLE_8({0xbc, 0x2a, 0x28, 0x86, 0x2c, 0xde, 0x8e, 0});
82 typedef Field<uint8_t, 8, 27, StatTable8, DynTable8, &SQR_TABLE_8, &QRT_TABLE_8> Field8;
83 #endif
84 }
85 
86 Sketch* 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)