/ src / minisketch / src / fields / generic_3bytes.cpp
generic_3bytes.cpp
  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_3)
 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_17
 23  // 17 bit field
 24  typedef RecLinTrans<uint32_t, 6, 6, 5> StatTable17;
 25  typedef RecLinTrans<uint32_t, 4, 4, 3, 3, 3> DynTable17;
 26  constexpr StatTable17 SQR_TABLE_17({0x1, 0x4, 0x10, 0x40, 0x100, 0x400, 0x1000, 0x4000, 0x10000, 0x12, 0x48, 0x120, 0x480, 0x1200, 0x4800, 0x12000, 0x8012});
 27  constexpr StatTable17 QRT_TABLE_17({0, 0x4c3e, 0x4c3c, 0x1a248, 0x4c38, 0x428, 0x1a240, 0x1b608, 0x4c28, 0x206, 0x408, 0x4000, 0x1a200, 0x18006, 0x1b688, 0x14d2e, 0x4d28});
 28  typedef Field<uint32_t, 17, 9, StatTable17, DynTable17, &SQR_TABLE_17, &QRT_TABLE_17> Field17;
 29  #endif
 30  
 31  #ifdef ENABLE_FIELD_INT_18
 32  // 18 bit field
 33  typedef RecLinTrans<uint32_t, 6, 6, 6> StatTable18;
 34  typedef RecLinTrans<uint32_t, 4, 4, 4, 3, 3> DynTable18;
 35  constexpr StatTable18 SQR_TABLE_18({0x1, 0x4, 0x10, 0x40, 0x100, 0x400, 0x1000, 0x4000, 0x10000, 0x9, 0x24, 0x90, 0x240, 0x900, 0x2400, 0x9000, 0x24000, 0x10012});
 36  constexpr StatTable18 QRT_TABLE_18({0x9208, 0x422, 0x420, 0x8048, 0x424, 0x68b0, 0x8040, 0x30086, 0x434, 0x1040, 0x6890, 0x30ca2, 0x8000, 0x32896, 0x30006, 0, 0x534, 0x20532});
 37  typedef Field<uint32_t, 18, 9, StatTable18, DynTable18, &SQR_TABLE_18, &QRT_TABLE_18> Field18;
 38  #endif
 39  
 40  #ifdef ENABLE_FIELD_INT_19
 41  // 19 bit field
 42  typedef RecLinTrans<uint32_t, 5, 5, 5, 4> StatTable19;
 43  typedef RecLinTrans<uint32_t, 4, 4, 4, 4, 3> DynTable19;
 44  constexpr StatTable19 SQR_TABLE_19({0x1, 0x4, 0x10, 0x40, 0x100, 0x400, 0x1000, 0x4000, 0x10000, 0x40000, 0x4e, 0x138, 0x4e0, 0x1380, 0x4e00, 0x13800, 0x4e000, 0x3804e, 0x6011f});
 45  constexpr StatTable19 QRT_TABLE_19({0x5d6b0, 0x2f476, 0x2f474, 0x1d6a2, 0x2f470, 0x42a, 0x1d6aa, 0x1060, 0x2f460, 0x19e92, 0x40a, 0x1da98, 0x1d6ea, 0x28c78, 0x10e0, 0xf56a, 0x2f560, 0, 0x19c92});
 46  typedef Field<uint32_t, 19, 39, StatTable19, DynTable19, &SQR_TABLE_19, &QRT_TABLE_19> Field19;
 47  #endif
 48  
 49  #ifdef ENABLE_FIELD_INT_20
 50  // 20 bit field
 51  typedef RecLinTrans<uint32_t, 5, 5, 5, 5> StatTable20;
 52  typedef RecLinTrans<uint32_t, 4, 4, 4, 4, 4> DynTable20;
 53  constexpr StatTable20 SQR_TABLE_20({0x1, 0x4, 0x10, 0x40, 0x100, 0x400, 0x1000, 0x4000, 0x10000, 0x40000, 0x9, 0x24, 0x90, 0x240, 0x900, 0x2400, 0x9000, 0x24000, 0x90000, 0x40012});
 54  constexpr StatTable20 QRT_TABLE_20({0xc5dea, 0xc0110, 0xc0112, 0xe11de, 0xc0116, 0x24814, 0xe11d6, 0x20080, 0xc0106, 0xfe872, 0x24834, 0xe4106, 0xe1196, 0x1d9a4, 0x20000, 0x31190, 0xc0006, 0, 0xfea72, 0x7ea74});
 55  typedef Field<uint32_t, 20, 9, StatTable20, DynTable20, &SQR_TABLE_20, &QRT_TABLE_20> Field20;
 56  #endif
 57  
 58  #ifdef ENABLE_FIELD_INT_21
 59  // 21 bit field
 60  typedef RecLinTrans<uint32_t, 6, 5, 5, 5> StatTable21;
 61  typedef RecLinTrans<uint32_t, 4, 4, 4, 3, 3, 3> DynTable21;
 62  constexpr StatTable21 SQR_TABLE_21({0x1, 0x4, 0x10, 0x40, 0x100, 0x400, 0x1000, 0x4000, 0x10000, 0x40000, 0x100000, 0xa, 0x28, 0xa0, 0x280, 0xa00, 0x2800, 0xa000, 0x28000, 0xa0000, 0x80005});
 63  constexpr StatTable21 QRT_TABLE_21({0x1bd5fc, 0xbc196, 0xbc194, 0x74b96, 0xbc190, 0x1048, 0x74b9e, 0x672c8, 0xbc180, 0x4080, 0x1068, 0xc8200, 0x74bde, 0x64280, 0x67248, 0xc4280, 0xbc080, 0x80000, 0x4280, 0, 0x1468});
 64  typedef Field<uint32_t, 21, 5, StatTable21, DynTable21, &SQR_TABLE_21, &QRT_TABLE_21> Field21;
 65  #endif
 66  
 67  #ifdef ENABLE_FIELD_INT_22
 68  // 22 bit field
 69  typedef RecLinTrans<uint32_t, 6, 6, 5, 5> StatTable22;
 70  typedef RecLinTrans<uint32_t, 4, 4, 4, 4, 3, 3> DynTable22;
 71  constexpr StatTable22 SQR_TABLE_22({0x1, 0x4, 0x10, 0x40, 0x100, 0x400, 0x1000, 0x4000, 0x10000, 0x40000, 0x100000, 0x3, 0xc, 0x30, 0xc0, 0x300, 0xc00, 0x3000, 0xc000, 0x30000, 0xc0000, 0x300000});
 72  constexpr StatTable22 QRT_TABLE_22({0x210d16, 0x104a, 0x1048, 0x4088, 0x104c, 0x200420, 0x4080, 0x492dc, 0x105c, 0x1a67f0, 0x200400, 0x21155c, 0x40c0, 0x20346c, 0x4925c, 0x1af7ac, 0x115c, 0x2274ac, 0x1a65f0, 0x2a65f0, 0x200000, 0});
 73  typedef Field<uint32_t, 22, 3, StatTable22, DynTable22, &SQR_TABLE_22, &QRT_TABLE_22> Field22;
 74  #endif
 75  
 76  #ifdef ENABLE_FIELD_INT_23
 77  // 23 bit field
 78  typedef RecLinTrans<uint32_t, 6, 6, 6, 5> StatTable23;
 79  typedef RecLinTrans<uint32_t, 4, 4, 4, 4, 4, 3> DynTable23;
 80  constexpr StatTable23 SQR_TABLE_23({0x1, 0x4, 0x10, 0x40, 0x100, 0x400, 0x1000, 0x4000, 0x10000, 0x40000, 0x100000, 0x400000, 0x42, 0x108, 0x420, 0x1080, 0x4200, 0x10800, 0x42000, 0x108000, 0x420000, 0x80042, 0x200108});
 81  constexpr StatTable23 QRT_TABLE_23({0, 0x1040, 0x1042, 0x43056, 0x1046, 0x121d76, 0x4305e, 0x40a0, 0x1056, 0x15176, 0x121d56, 0x7ee1f6, 0x4301e, 0x40000, 0x4020, 0x4f0be, 0x1156, 0x7cf0a0, 0x15376, 0x1ee9e8, 0x121956, 0x3ac9f6, 0x7ee9f6});
 82  typedef Field<uint32_t, 23, 33, StatTable23, DynTable23, &SQR_TABLE_23, &QRT_TABLE_23> Field23;
 83  #endif
 84  
 85  #ifdef ENABLE_FIELD_INT_24
 86  // 24 bit field
 87  typedef RecLinTrans<uint32_t, 6, 6, 6, 6> StatTable24;
 88  typedef RecLinTrans<uint32_t, 4, 4, 4, 4, 4, 4> DynTable24;
 89  constexpr StatTable24 SQR_TABLE_24({0x1, 0x4, 0x10, 0x40, 0x100, 0x400, 0x1000, 0x4000, 0x10000, 0x40000, 0x100000, 0x400000, 0x1b, 0x6c, 0x1b0, 0x6c0, 0x1b00, 0x6c00, 0x1b000, 0x6c000, 0x1b0000, 0x6c0000, 0xb0001b, 0xc0005a});
 90  constexpr StatTable24 QRT_TABLE_24({0x104e, 0xaf42a8, 0xaf42aa, 0xb78186, 0xaf42ae, 0x4090, 0xb7818e, 0x4a37c, 0xaf42be, 0x3688c0, 0x40b0, 0x80080e, 0xb781ce, 0xaf2232, 0x4a3fc, 0x856a82, 0xaf43be, 0x29c970, 0x368ac0, 0x968ace, 0x44b0, 0x77d570, 0x80000e, 0});
 91  typedef Field<uint32_t, 24, 27, StatTable24, DynTable24, &SQR_TABLE_24, &QRT_TABLE_24> Field24;
 92  #endif
 93  }
 94  
 95  Sketch* ConstructGeneric3Bytes(int bits, int implementation)
 96  {
 97      switch (bits) {
 98  #ifdef ENABLE_FIELD_INT_17
 99      case 17: return new SketchImpl<Field17>(implementation, 17);
100  #endif
101  #ifdef ENABLE_FIELD_INT_18
102      case 18: return new SketchImpl<Field18>(implementation, 18);
103  #endif
104  #ifdef ENABLE_FIELD_INT_19
105      case 19: return new SketchImpl<Field19>(implementation, 19);
106  #endif
107  #ifdef ENABLE_FIELD_INT_20
108      case 20: return new SketchImpl<Field20>(implementation, 20);
109  #endif
110  #ifdef ENABLE_FIELD_INT_21
111      case 21: return new SketchImpl<Field21>(implementation, 21);
112  #endif
113  #ifdef ENABLE_FIELD_INT_22
114      case 22: return new SketchImpl<Field22>(implementation, 22);
115  #endif
116  #ifdef ENABLE_FIELD_INT_23
117      case 23: return new SketchImpl<Field23>(implementation, 23);
118  #endif
119  #ifdef ENABLE_FIELD_INT_24
120      case 24: return new SketchImpl<Field24>(implementation, 24);
121  #endif
122      default: return nullptr;
123      }
124  }