barry: Your go-to motif accountant
0.0-1
Full enumeration of sample space and fast count of sufficient statistics for binary arrays
|
Baseline class for binary arrays. More...
#include <barray-bones.hpp>
Public Member Functions | |||||||||||
bool | operator== (const BArray< Cell_Type, Data_Type > &Array_) | ||||||||||
~BArray () | |||||||||||
void | out_of_range (size_t i, size_t j) const | ||||||||||
Cell_Type | get_cell (size_t i, size_t j, bool check_bounds=true) const | ||||||||||
std::vector< Cell_Type > | get_col_vec (size_t i, bool check_bounds=true) const | ||||||||||
std::vector< Cell_Type > | get_row_vec (size_t i, bool check_bounds=true) const | ||||||||||
void | get_col_vec (std::vector< Cell_Type > *x, size_t i, bool check_bounds=true) const | ||||||||||
void | get_row_vec (std::vector< Cell_Type > *x, size_t i, bool check_bounds=true) const | ||||||||||
const Row_type< Cell_Type > & | row (size_t i, bool check_bounds=true) const | ||||||||||
const Col_type< Cell_Type > & | col (size_t i, bool check_bounds=true) const | ||||||||||
Entries< Cell_Type > | get_entries () const | ||||||||||
Get the edgelist. More... | |||||||||||
void | transpose () | ||||||||||
void | clear (bool hard=true) | ||||||||||
void | resize (size_t N_, size_t M_) | ||||||||||
void | reserve () | ||||||||||
void | print (const char *fmt=nullptr,...) const | ||||||||||
void | print_n (size_t nrow, size_t ncol, const char *fmt=nullptr,...) const | ||||||||||
bool | is_dense () const noexcept | ||||||||||
Constructors | |||||||||||
| |||||||||||
BArray () | |||||||||||
Zero-size array. More... | |||||||||||
BArray (size_t N_, size_t M_) | |||||||||||
Empty array. More... | |||||||||||
BArray (size_t N_, size_t M_, const std::vector< size_t > &source, const std::vector< size_t > &target, const std::vector< Cell_Type > &value, bool add=true) | |||||||||||
Edgelist with data. More... | |||||||||||
BArray (size_t N_, size_t M_, const std::vector< size_t > &source, const std::vector< size_t > &target, bool add=true) | |||||||||||
Edgelist with no data (simpler) More... | |||||||||||
BArray (const BArray< Cell_Type, Data_Type > &Array_, bool copy_data=false) | |||||||||||
Copy constructor. More... | |||||||||||
BArray< Cell_Type, Data_Type > & | operator= (const BArray< Cell_Type, Data_Type > &Array_) | ||||||||||
Assignment constructor. More... | |||||||||||
BArray (BArray< Cell_Type, Data_Type > &&x) noexcept | |||||||||||
Move operator. More... | |||||||||||
BArray< Cell_Type, Data_Type > & | operator= (BArray< Cell_Type, Data_Type > &&x) noexcept | ||||||||||
Move assignment. More... | |||||||||||
void | set_data (Data_Type *data_, bool delete_data_=false) | ||||||||||
Set the data object. More... | |||||||||||
Data_Type * | D_ptr () | ||||||||||
const Data_Type * | D_ptr () const | ||||||||||
Data_Type & | D () | ||||||||||
const Data_Type & | D () const | ||||||||||
void | flush_data () | ||||||||||
Queries | |||||||||||
| |||||||||||
bool | is_empty (size_t i, size_t j, bool check_bounds=true) const | ||||||||||
size_t | nrow () const noexcept | ||||||||||
size_t | ncol () const noexcept | ||||||||||
size_t | nnozero () const noexcept | ||||||||||
Cell< Cell_Type > | default_val () const | ||||||||||
Cell-wise insertion/deletion | |||||||||||
| |||||||||||
BArray< Cell_Type, Data_Type > & | operator+= (const std::pair< size_t, size_t > &coords) | ||||||||||
BArray< Cell_Type, Data_Type > & | operator-= (const std::pair< size_t, size_t > &coords) | ||||||||||
BArrayCell< Cell_Type, Data_Type > | operator() (size_t i, size_t j, bool check_bounds=true) | ||||||||||
const Cell_Type | operator() (size_t i, size_t j, bool check_bounds=true) const | ||||||||||
void | rm_cell (size_t i, size_t j, bool check_bounds=true, bool check_exists=true) | ||||||||||
void | insert_cell (size_t i, size_t j, const Cell< Cell_Type > &v, bool check_bounds, bool check_exists) | ||||||||||
void | insert_cell (size_t i, size_t j, Cell< Cell_Type > &&v, bool check_bounds, bool check_exists) | ||||||||||
void | insert_cell (size_t i, size_t j, Cell_Type v, bool check_bounds, bool check_exists) | ||||||||||
void | swap_cells (size_t i0, size_t j0, size_t i1, size_t j1, bool check_bounds=true, int check_exists=CHECK::BOTH, int *report=nullptr) | ||||||||||
void | toggle_cell (size_t i, size_t j, bool check_bounds=true, int check_exists=EXISTS::UKNOWN) | ||||||||||
void | toggle_lock (size_t i, size_t j, bool check_bounds=true) | ||||||||||
Column/row wise interchange | |||||||||||
void | swap_rows (size_t i0, size_t i1, bool check_bounds=true) | ||||||||||
void | swap_cols (size_t j0, size_t j1, bool check_bounds=true) | ||||||||||
void | zero_row (size_t i, bool check_bounds=true) | ||||||||||
void | zero_col (size_t j, bool check_bounds=true) | ||||||||||
Arithmetic operators | |||||||||||
BArray< Cell_Type, Data_Type > & | operator+= (const BArray< Cell_Type, Data_Type > &rhs) | ||||||||||
BArray< Cell_Type, Data_Type > & | operator+= (const Cell_Type &rhs) | ||||||||||
BArray< Cell_Type, Data_Type > & | operator-= (const BArray< Cell_Type, Data_Type > &rhs) | ||||||||||
BArray< Cell_Type, Data_Type > & | operator-= (const Cell_Type &rhs) | ||||||||||
BArray< Cell_Type, Data_Type > & | operator/= (const Cell_Type &rhs) | ||||||||||
BArray< Cell_Type, Data_Type > & | operator*= (const Cell_Type &rhs) | ||||||||||
Public Attributes | |
bool | visited = false |
Friends | |
class | BArrayCell< Cell_Type, Data_Type > |
class | BArrayCell_const< Cell_Type, Data_Type > |
Baseline class for binary arrays.
BArray
class objects are arbitrary arrays in which non-empty cells hold data of type Cell_Type
. The non-empty cells are stored by row and indexed using unordered_map
s, i.e. std::vector< std::unordered_map<size_t,Cell_Type> >
.
Cell_Type | Type of cell (any type). |
Data_Type | Data type of the array (bool default). |
Definition at line 28 of file barray-bones.hpp.
|
inline |
Zero-size array.
Definition at line 69 of file barray-bones.hpp.
|
inline |
Empty array.
Definition at line 72 of file barray-bones.hpp.
BArray< Cell_Type, Data_Type >::BArray | ( | size_t | N_, |
size_t | M_, | ||
const std::vector< size_t > & | source, | ||
const std::vector< size_t > & | target, | ||
const std::vector< Cell_Type > & | value, | ||
bool | add = true |
||
) |
Edgelist with data.
BArray< Cell_Type, Data_Type >::BArray | ( | size_t | N_, |
size_t | M_, | ||
const std::vector< size_t > & | source, | ||
const std::vector< size_t > & | target, | ||
bool | add = true |
||
) |
Edgelist with no data (simpler)
BArray< Cell_Type, Data_Type >::BArray | ( | const BArray< Cell_Type, Data_Type > & | Array_, |
bool | copy_data = false |
||
) |
Copy constructor.
|
noexcept |
Move operator.
BArray< Cell_Type, Data_Type >::~BArray | ( | ) |
void BArray< Cell_Type, Data_Type >::clear | ( | bool | hard = true | ) |
const Col_type< Cell_Type >& BArray< Cell_Type, Data_Type >::col | ( | size_t | i, |
bool | check_bounds = true |
||
) | const |
Data_Type& BArray< Cell_Type, Data_Type >::D | ( | ) |
const Data_Type& BArray< Cell_Type, Data_Type >::D | ( | ) | const |
Data_Type* BArray< Cell_Type, Data_Type >::D_ptr | ( | ) |
const Data_Type* BArray< Cell_Type, Data_Type >::D_ptr | ( | ) | const |
Cell<Cell_Type> BArray< Cell_Type, Data_Type >::default_val | ( | ) | const |
void BArray< Cell_Type, Data_Type >::flush_data | ( | ) |
Cell_Type BArray< Cell_Type, Data_Type >::get_cell | ( | size_t | i, |
size_t | j, | ||
bool | check_bounds = true |
||
) | const |
std::vector< Cell_Type > BArray< Cell_Type, Data_Type >::get_col_vec | ( | size_t | i, |
bool | check_bounds = true |
||
) | const |
void BArray< Cell_Type, Data_Type >::get_col_vec | ( | std::vector< Cell_Type > * | x, |
size_t | i, | ||
bool | check_bounds = true |
||
) | const |
Entries<Cell_Type> BArray< Cell_Type, Data_Type >::get_entries | ( | ) | const |
Get the edgelist.
Entries
is a class with three objects: Two std::vector
with the row and column coordinates respectively, and one std::vector
with the corresponding value of the cell.
std::vector< Cell_Type > BArray< Cell_Type, Data_Type >::get_row_vec | ( | size_t | i, |
bool | check_bounds = true |
||
) | const |
void BArray< Cell_Type, Data_Type >::get_row_vec | ( | std::vector< Cell_Type > * | x, |
size_t | i, | ||
bool | check_bounds = true |
||
) | const |
void BArray< Cell_Type, Data_Type >::insert_cell | ( | size_t | i, |
size_t | j, | ||
Cell< Cell_Type > && | v, | ||
bool | check_bounds, | ||
bool | check_exists | ||
) |
void BArray< Cell_Type, Data_Type >::insert_cell | ( | size_t | i, |
size_t | j, | ||
Cell_Type | v, | ||
bool | check_bounds, | ||
bool | check_exists | ||
) |
void BArray< Cell_Type, Data_Type >::insert_cell | ( | size_t | i, |
size_t | j, | ||
const Cell< Cell_Type > & | v, | ||
bool | check_bounds, | ||
bool | check_exists | ||
) |
|
inlinenoexcept |
Definition at line 241 of file barray-bones.hpp.
bool BArray< Cell_Type, Data_Type >::is_empty | ( | size_t | i, |
size_t | j, | ||
bool | check_bounds = true |
||
) | const |
|
noexcept |
|
noexcept |
|
noexcept |
BArrayCell<Cell_Type,Data_Type> BArray< Cell_Type, Data_Type >::operator() | ( | size_t | i, |
size_t | j, | ||
bool | check_bounds = true |
||
) |
const Cell_Type BArray< Cell_Type, Data_Type >::operator() | ( | size_t | i, |
size_t | j, | ||
bool | check_bounds = true |
||
) | const |
BArray<Cell_Type,Data_Type>& BArray< Cell_Type, Data_Type >::operator*= | ( | const Cell_Type & | rhs | ) |
BArray<Cell_Type,Data_Type>& BArray< Cell_Type, Data_Type >::operator+= | ( | const BArray< Cell_Type, Data_Type > & | rhs | ) |
BArray<Cell_Type,Data_Type>& BArray< Cell_Type, Data_Type >::operator+= | ( | const Cell_Type & | rhs | ) |
BArray<Cell_Type,Data_Type>& BArray< Cell_Type, Data_Type >::operator+= | ( | const std::pair< size_t, size_t > & | coords | ) |
BArray<Cell_Type,Data_Type>& BArray< Cell_Type, Data_Type >::operator-= | ( | const BArray< Cell_Type, Data_Type > & | rhs | ) |
BArray<Cell_Type,Data_Type>& BArray< Cell_Type, Data_Type >::operator-= | ( | const Cell_Type & | rhs | ) |
BArray<Cell_Type,Data_Type>& BArray< Cell_Type, Data_Type >::operator-= | ( | const std::pair< size_t, size_t > & | coords | ) |
BArray<Cell_Type,Data_Type>& BArray< Cell_Type, Data_Type >::operator/= | ( | const Cell_Type & | rhs | ) |
|
noexcept |
Move assignment.
BArray<Cell_Type,Data_Type>& BArray< Cell_Type, Data_Type >::operator= | ( | const BArray< Cell_Type, Data_Type > & | Array_ | ) |
Assignment constructor.
bool BArray< Cell_Type, Data_Type >::operator== | ( | const BArray< Cell_Type, Data_Type > & | Array_ | ) |
void BArray< Cell_Type, Data_Type >::out_of_range | ( | size_t | i, |
size_t | j | ||
) | const |
void BArray< Cell_Type, Data_Type >::print | ( | const char * | fmt = nullptr , |
... | |||
) | const |
void BArray< Cell_Type, Data_Type >::print_n | ( | size_t | nrow, |
size_t | ncol, | ||
const char * | fmt = nullptr , |
||
... | |||
) | const |
void BArray< Cell_Type, Data_Type >::reserve | ( | ) |
void BArray< Cell_Type, Data_Type >::resize | ( | size_t | N_, |
size_t | M_ | ||
) |
void BArray< Cell_Type, Data_Type >::rm_cell | ( | size_t | i, |
size_t | j, | ||
bool | check_bounds = true , |
||
bool | check_exists = true |
||
) |
const Row_type< Cell_Type >& BArray< Cell_Type, Data_Type >::row | ( | size_t | i, |
bool | check_bounds = true |
||
) | const |
void BArray< Cell_Type, Data_Type >::set_data | ( | Data_Type * | data_, |
bool | delete_data_ = false |
||
) |
Set the data object.
data_ | |
delete_data_ |
void BArray< Cell_Type, Data_Type >::swap_cells | ( | size_t | i0, |
size_t | j0, | ||
size_t | i1, | ||
size_t | j1, | ||
bool | check_bounds = true , |
||
int | check_exists = CHECK::BOTH , |
||
int * | report = nullptr |
||
) |
void BArray< Cell_Type, Data_Type >::swap_cols | ( | size_t | j0, |
size_t | j1, | ||
bool | check_bounds = true |
||
) |
void BArray< Cell_Type, Data_Type >::swap_rows | ( | size_t | i0, |
size_t | i1, | ||
bool | check_bounds = true |
||
) |
void BArray< Cell_Type, Data_Type >::toggle_cell | ( | size_t | i, |
size_t | j, | ||
bool | check_bounds = true , |
||
int | check_exists = EXISTS::UKNOWN |
||
) |
void BArray< Cell_Type, Data_Type >::toggle_lock | ( | size_t | i, |
size_t | j, | ||
bool | check_bounds = true |
||
) |
void BArray< Cell_Type, Data_Type >::transpose | ( | ) |
void BArray< Cell_Type, Data_Type >::zero_col | ( | size_t | j, |
bool | check_bounds = true |
||
) |
void BArray< Cell_Type, Data_Type >::zero_row | ( | size_t | i, |
bool | check_bounds = true |
||
) |
|
friend |
Definition at line 1 of file barray-bones.hpp.
|
friend |
Definition at line 1 of file barray-bones.hpp.
bool BArray< Cell_Type, Data_Type >::visited = false |
This is as a reference, if we need to iterate through the cells and we need to keep track which were visited, we use this as a reference. So that if cell.visited = true and visited = true, it means that we haven't been here yet. Ideally, any routine using this->visited should switch it at the beginning of the routine.
Definition at line 54 of file barray-bones.hpp.