Skip to content

Commit

Permalink
patch: remove required_bits and pow function
Browse files Browse the repository at this point in the history
  • Loading branch information
SGSSGene committed Aug 27, 2024
1 parent 5fc059f commit 7c1b0ee
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 107 deletions.
6 changes: 0 additions & 6 deletions src/fmindex-collection/occtable/EPRV8.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

#include "../builtins.h"
#include "concepts.h"
#include "utils.h"

#include <algorithm>
#include <array>
Expand All @@ -29,11 +28,6 @@ struct Bitvector {
size_t bitct{size_t(std::ceil(std::log2(sigma)))};
size_t bvct{size_t(std::exp2(bitct))};

// number of full length bitvectors needed `2^bitct ≥ TSigma`
// static constexpr auto bitct = required_bits(TSigma-1);
// next full power of 2
// static constexpr auto bvct = pow(2, bitct);

struct InBitsView {
uint64_t const* bits;
size_t const bitct;
Expand Down
31 changes: 0 additions & 31 deletions src/fmindex-collection/occtable/utils.h

This file was deleted.

6 changes: 3 additions & 3 deletions src/fmindex-collection/rankvector/DenseEPRV6.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

#include "../DenseVector.h"
#include "concepts.h"
#include "utils.h"

#include <bit>
#include <bitset>
#include <vector>

Expand All @@ -16,9 +16,9 @@ template <size_t TSigma>
struct DenseEPRV6 {

// number of full length bitvectors needed `2^bitct ≥ TSigma`
static constexpr auto bitct = required_bits(TSigma-1);
static constexpr auto bitct = std::bit_width(TSigma-1);
// next full power of 2
static constexpr auto bvct = pow(2, bitct);
static constexpr auto bvct = std::bit_ceil(TSigma);

struct InBits {
std::array<uint64_t, bitct> bits{};
Expand Down
6 changes: 3 additions & 3 deletions src/fmindex-collection/rankvector/EPRV3.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#pragma once

#include "concepts.h"
#include "utils.h"

#include <bit>
#include <bitset>
#include <cassert>
#include <vector>
Expand All @@ -18,9 +18,9 @@ struct EPRV3 {
static constexpr size_t Sigma = TSigma;

// number of full length bitvectors needed `2^bitct ≥ TSigma`
static constexpr auto bitct = required_bits(TSigma-1);
static constexpr auto bitct = std::bit_width(TSigma-1);
// next full power of 2
static constexpr auto bvct = pow(2, bitct);
static constexpr auto bvct = std::bit_ceil(TSigma);

struct Block {
std::array<block_t, TSigma> blocks{};
Expand Down
6 changes: 3 additions & 3 deletions src/fmindex-collection/rankvector/EPRV4.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#pragma once

#include "concepts.h"
#include "utils.h"
#include "EPRV3.h"

#include <bit>
#include <vector>

namespace fmindex_collection::rankvector {
Expand All @@ -17,9 +17,9 @@ struct EPRV4 {
static constexpr size_t Sigma = TSigma;

// number of full length bitvectors needed `2^bitct ≥ TSigma`
static constexpr auto bitct = required_bits(TSigma-1);
static constexpr auto bitct = std::bit_width(TSigma-1);
// next full power of 2
static constexpr auto bvct = pow(2, bitct);
static constexpr auto bvct = std::bit_ceil(TSigma);

using InBits = typename EPRV3<TSigma>::InBits;

Expand Down
6 changes: 3 additions & 3 deletions src/fmindex-collection/rankvector/EPRV5.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#pragma once

#include "concepts.h"
#include "utils.h"
#include "EPRV3.h"

#include <bit>
#include <vector>

namespace fmindex_collection::rankvector {
Expand All @@ -17,9 +17,9 @@ struct EPRV5 {
static constexpr size_t Sigma = TSigma;

// number of full length bitvectors needed `2^bitct ≥ TSigma`
static constexpr auto bitct = required_bits(TSigma-1);
static constexpr auto bitct = std::bit_width(TSigma-1);
// next full power of 2
static constexpr auto bvct = pow(2, bitct);
static constexpr auto bvct = std::bit_ceil(TSigma);

using InBits = typename EPRV3<TSigma>::InBits;

Expand Down
5 changes: 2 additions & 3 deletions src/fmindex-collection/rankvector/InterleavedEPR.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#pragma once

#include "concepts.h"
#include "utils.h"

#include <bitset>
#include <cassert>
Expand All @@ -18,10 +17,10 @@ struct InterleavedEPR {
static constexpr size_t Sigma = TSigma;

// number of full length bitvectors needed `2^bitct ≥ TSigma`
static constexpr auto bitct = required_bits(TSigma-1);
static constexpr auto bitct = std::bit_width(TSigma-1);

// next full power of 2
static constexpr auto bvct = pow(2, bitct);
static constexpr auto bvct = std::bit_ceil(TSigma);

// To select a char at the even/uneven position
static constexpr uint64_t maskEven = []() {
Expand Down
4 changes: 2 additions & 2 deletions src/fmindex-collection/rankvector/InterleavedEPRV2.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

#include "../builtins.h"
#include "concepts.h"
#include "utils.h"

#include <bit>
#include <bitset>
#include <cassert>
#include <cstdint>
Expand Down Expand Up @@ -55,7 +55,7 @@ struct InterleavedEPRV2 {
}

// number of full length bitvectors needed `2^sigma_bits ≥ TSigma`
static constexpr auto sigma_bits = required_bits(TSigma-1);
static constexpr auto sigma_bits = std::bit_width(TSigma-1);

struct alignas(TAlignment) Block {
std::array<block_t, TSigma> blocks{};
Expand Down
4 changes: 2 additions & 2 deletions src/fmindex-collection/rankvector/InterleavedEPRV7.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#pragma once

#include "concepts.h"
#include "utils.h"

#include <bit>
#include <bitset>
#include <cassert>
#include <vector>
Expand All @@ -18,7 +18,7 @@ struct InterleavedEPRV7 {
static constexpr size_t Sigma = TSigma;

// number of full length bitvectors needed `2^bitct ≥ TSigma`
static constexpr auto bitct = required_bits(TSigma-1);
static constexpr auto bitct = std::bit_width(TSigma-1);

#pragma pack(push, 1)
struct InBits {
Expand Down
6 changes: 3 additions & 3 deletions src/fmindex-collection/rankvector/Wavelet.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
#include "../bitvector/Bitvector.h"
#include "../bitvector/PrunedBitvector.h"
#include "concepts.h"
#include "utils.h"

#include <algorithm>
#include <array>
#include <bit>
#include <bitset>
#include <cassert>
#include <cstdint>
Expand All @@ -28,8 +28,8 @@ template <size_t TSigma, BitVector_c Bitvector = ::fmindex_collection::bitvector
struct Wavelet {
static constexpr size_t Sigma = TSigma;

static constexpr auto bits = required_bits(TSigma-1);
static constexpr auto bvct = pow(2, bits);
static constexpr auto bits = std::bit_width(TSigma-1);
static constexpr auto bvct = std::bit_ceil(TSigma);

std::array<Bitvector, bvct> bitvector;
size_t totalLength;
Expand Down
12 changes: 6 additions & 6 deletions src/fmindex-collection/rankvector/Wavelet2.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
#include "../builtins.h"
#include "../bitvector/Bitvector.h"
#include "concepts.h"
#include "utils.h"

#include <algorithm>
#include <array>
#include <bit>
#include <bitset>
#include <cassert>
#include <cstdint>
Expand All @@ -27,8 +27,8 @@ template <size_t TSigma, BitVector_c Bitvector = ::fmindex_collection::bitvector
struct Wavelet2 {
static constexpr size_t Sigma = TSigma;

static constexpr auto bits = required_bits(TSigma-1);
static constexpr auto bvct = pow(2, bits);
static constexpr auto bits = std::bit_width(TSigma-1);
static constexpr auto bvct = std::bit_ceil(TSigma);

std::array<Bitvector, bvct> bitvector;
size_t totalLength;
Expand Down Expand Up @@ -134,7 +134,7 @@ struct Wavelet2 {
if (nbr == 1) return 0;
if (nbr == 2) return 1;
auto bits = required_bits(nbr-1);
auto bits = std::bit_width(nbr-1);
auto leftNbr = pow(2, bits-1);
auto rightNbr = nbr-leftNbr;
auto cl = divide(leftNbr);
Expand All @@ -155,8 +155,8 @@ struct Wavelet2 {
auto res = std::vector<std::tuple<uint8_t, uint8_t>>{};
auto bit = (symb >> (bits-Depth)) & 1;

constexpr auto bits = required_bits(Sigma-1);
constexpr auto leftNbr = pow(2, bits-1);
constexpr auto bits = std::bit_width(Sigma-1);
constexpr auto leftNbr = std::bit_ceil(Sigma-1);
constexpr auto rightNbr = Sigma - leftNbr;
if (symb < leftNbr) {
assert(bit == 0);
Expand Down
42 changes: 0 additions & 42 deletions src/fmindex-collection/rankvector/utils.h

This file was deleted.

0 comments on commit 7c1b0ee

Please sign in to comment.