BitMagic-C++
Typedefs | Functions | Variables
xsample09.cpp File Reference

Example: Use succinct vectors for histogram construction. More...

#include <iostream>
#include <memory>
#include <vector>
#include <random>
#include <algorithm>
#include <stdexcept>
#include "bm.h"
#include "bmtimer.h"
#include "bmsparsevec.h"
#include "bmsparsevec_compr.h"
#include "bmdbg.h"
#include "bmundef.h"
Include dependency graph for xsample09.cpp:

Go to the source code of this file.

Typedefs

typedef bm::bvector bvector_type
 
typedef bvector_type::size_type bv_size_type
 
typedef bm::sparse_vector< unsigned, bvector_typesparse_vector_u32
 
typedef bm::rsc_sparse_vector< unsigned, sparse_vector_u32rsc_sparse_vector_u32
 
typedef std::vector< std::pair< bv_size_type, bv_size_type > > bv_ranges_vector
 

Functions

static void generate_test_data (rsc_sparse_vector_u32 &csv, unsigned size)
 Generate a test RSC vector with a randomly distributed values imitating distribution density of genome variations it adds a huge area of empty in the middle to simulate chr centromere. More...
 
static void generate_access_samples (std::vector< bvector_type::size_type > &sample_vec, unsigned size)
 generate list of random indexes (locations) to read histogram values More...
 
static void compute_historgam (sparse_vector_u32 &hist_sv, const rsc_sparse_vector_u32 &csv, sparse_vector_u32::size_type sampling_size)
 Compute histogram as a SV vector using fixed sampling interval. More...
 
static void compute_rsc_historgam (rsc_sparse_vector_u32 &hist_rsc, const rsc_sparse_vector_u32 &csv, sparse_vector_u32::size_type sampling_size)
 Compute histogram as a RSC vector using fixed sampling interval. More...
 
static void compute_adaptive_rsc_histogram (rsc_sparse_vector_u32 &hist_rsc, const rsc_sparse_vector_u32 &csv, sparse_vector_u32::size_type sampling_size)
 Adaptive histogram identifies number of not NULL elements (events) and varies the size of the histogram bin trying to make sure all bins (but last) are the same weight. More...
 
static void verify_histograms (const rsc_sparse_vector_u32 &hist_rsc, const sparse_vector_u32 &hist_sv, sparse_vector_u32::size_type sampling_size)
 Some test to confirm correctness. More...
 
static unsigned long long access_bench1 (const sparse_vector_u32 &hist_sv, const std::vector< bvector_type::size_type > &sample_vec, unsigned sampling_size)
 Access benchmark 1. More...
 
static unsigned long long access_bench2 (const rsc_sparse_vector_u32 &hist_rsc, const std::vector< bvector_type::size_type > &sample_vec)
 Access benchmark 2. More...
 
static void access_bench3 (const rsc_sparse_vector_u32 &hist_rsc, const std::vector< bvector_type::size_type > &sample_vec, const rsc_sparse_vector_u32 &rsc_data)
  More...
 
int main (void)
  More...
 

Variables

const unsigned test_size = 250000000
  More...
 
const unsigned sampling_interval = 2500
  More...
 
bm::chrono_taker ::duration_map_type timing_map
  More...
 

Detailed Description

Example: Use succinct vectors for histogram construction.

Definition in file xsample09.cpp.

Function Documentation

◆ access_bench1()

static unsigned long long access_bench1 ( const sparse_vector_u32 hist_sv,
const std::vector< bvector_type::size_type > &  sample_vec,
unsigned  sampling_size 
)
static

Access benchmark 1.

uses regular bit-transposed sparse vector to read histogram values in random order. It relies on fixed inetrval sampling.

Examples
xsample09.cpp.

Definition at line 273 of file xsample09.cpp.

Referenced by main().

◆ access_bench2()

static unsigned long long access_bench2 ( const rsc_sparse_vector_u32 hist_rsc,
const std::vector< bvector_type::size_type > &  sample_vec 
)
static

Access benchmark 2.

Uses Rank-Select bit-transposed vector to read histogram values Sampling interval can be non-fixed (variadic, adaptive sampling). Method finds the interval start and value using RSC container not NULL vector

Examples
xsample09.cpp.

Definition at line 294 of file xsample09.cpp.

References bm::bvector< Alloc >::find_reverse(), and bm::rsc_sparse_vector< Val, SV >::get_null_bvector().

Referenced by main().

◆ access_bench3()

static void access_bench3 ( const rsc_sparse_vector_u32 hist_rsc,
const std::vector< bvector_type::size_type > &  sample_vec,
const rsc_sparse_vector_u32 rsc_data 
)
static

◆ compute_adaptive_rsc_histogram()

static void compute_adaptive_rsc_histogram ( rsc_sparse_vector_u32 hist_rsc,
const rsc_sparse_vector_u32 csv,
sparse_vector_u32::size_type  sampling_size 
)
static

Adaptive histogram identifies number of not NULL elements (events) and varies the size of the histogram bin trying to make sure all bins (but last) are the same weight.

Examples
xsample09.cpp.

Definition at line 220 of file xsample09.cpp.

References BM_DECLARE_TEMP_BLOCK, bm::rsc_sparse_vector< Val, SV >::get_null_bvector(), bm::rsc_sparse_vector< Val, SV >::optimize(), bm::rsc_sparse_vector< Val, SV >::push_back(), bm::rank_range_split(), and bm::rsc_sparse_vector< Val, SV >::sync().

Referenced by main().

◆ compute_historgam()

static void compute_historgam ( sparse_vector_u32 hist_sv,
const rsc_sparse_vector_u32 csv,
sparse_vector_u32::size_type  sampling_size 
)
static

◆ compute_rsc_historgam()

static void compute_rsc_historgam ( rsc_sparse_vector_u32 hist_rsc,
const rsc_sparse_vector_u32 csv,
sparse_vector_u32::size_type  sampling_size 
)
static

Compute histogram as a RSC vector using fixed sampling interval.

Histogram values are stored as "true" interval start coordinates and it is a more flexible scheme if we eventually decide to use adaptive sampling (variable step).

Examples
xsample09.cpp.

Definition at line 180 of file xsample09.cpp.

References BM_DECLARE_TEMP_BLOCK, bm::rsc_sparse_vector< Val, SV >::get_null_bvector(), bm::rsc_sparse_vector< Val, SV >::load_from(), bm::rsc_sparse_vector< Val, SV >::optimize(), bm::sparse_vector< Val, BV >::set(), bm::rsc_sparse_vector< Val, SV >::size(), bm::rsc_sparse_vector< Val, SV >::sync(), and bm::use_null.

Referenced by main().

◆ generate_access_samples()

static void generate_access_samples ( std::vector< bvector_type::size_type > &  sample_vec,
unsigned  size 
)
static

generate list of random indexes (locations) to read histogram values

Examples
xsample09.cpp.

Definition at line 124 of file xsample09.cpp.

Referenced by main().

◆ generate_test_data()

static void generate_test_data ( rsc_sparse_vector_u32 csv,
unsigned  size 
)
static

Generate a test RSC vector with a randomly distributed values imitating distribution density of genome variations it adds a huge area of empty in the middle to simulate chr centromere.

Examples
xsample09.cpp.

Definition at line 83 of file xsample09.cpp.

References BM_DECLARE_TEMP_BLOCK, bm::rsc_sparse_vector< Val, SV >::get_back_inserter(), bm::rsc_sparse_vector< Val, SV >::optimize(), and bm::rsc_sparse_vector< Val, SV >::sync().

Referenced by main().

◆ main()

int main ( void  )

◆ verify_histograms()

static void verify_histograms ( const rsc_sparse_vector_u32 hist_rsc,
const sparse_vector_u32 hist_sv,
sparse_vector_u32::size_type  sampling_size 
)
static

Some test to confirm correctness.

Examples
xsample09.cpp.

Definition at line 246 of file xsample09.cpp.

References bm::rsc_sparse_vector< Val, SV >::get_null_bvector().

Referenced by main().