7 #ifndef BARRAY_BONES_HPP
8 #define BARRAY_BONES_HPP 1
10 template<
typename Cell_Type,
typename Data_Type>
13 template<
typename Cell_Type,
typename Data_Type>
27 template <
typename Cell_Type =
bool,
typename Data_Type =
bool>
37 std::vector< Row_type< Cell_Type > > el_ij;
38 std::vector< Col_type< Cell_Type > > el_ji;
39 Data_Type *
data =
nullptr;
40 bool delete_data =
false;
43 static const bool dense =
false;
69 BArray() : N(0u), M(0u), NCells(0u), el_ij(0u), el_ji(0u) {};
72 BArray (
size_t N_,
size_t M_) : N(N_), M(M_), NCells(0u), el_ij(N_), el_ji(M_) {};
77 const std::vector< size_t > & source,
78 const std::vector< size_t > & target,
79 const std::vector< Cell_Type > & value,
86 const std::vector< size_t > & source,
87 const std::vector< size_t > & target,
123 const Data_Type &
D()
const;
130 Cell_Type
get_cell(
size_t i,
size_t j,
bool check_bounds =
true)
const;
131 std::vector< Cell_Type >
get_col_vec(
size_t i,
bool check_bounds =
true)
const;
132 std::vector< Cell_Type >
get_row_vec(
size_t i,
bool check_bounds =
true)
const;
133 void get_col_vec(std::vector< Cell_Type > * x,
size_t i,
bool check_bounds =
true)
const;
134 void get_row_vec(std::vector< Cell_Type > * x,
size_t i,
bool check_bounds =
true)
const;
157 bool is_empty(
size_t i,
size_t j,
bool check_bounds =
true)
const;
174 BArray<Cell_Type,Data_Type> & operator+=(const std::pair<
size_t,
size_t> & coords);
175 BArray<Cell_Type,Data_Type> & operator-=(const std::pair<
size_t,
size_t> & coords);
176 BArrayCell<Cell_Type,Data_Type> operator()(
size_t i,
size_t j,
bool check_bounds = true);
177 const Cell_Type operator()(
size_t i,
size_t j,
bool check_bounds = true) const;
179 void rm_cell(
size_t i,
size_t j,
bool check_bounds = true,
bool check_exists = true);
181 void insert_cell(
size_t i,
size_t j, const
Cell< Cell_Type > & v,
bool check_bounds,
bool check_exists);
182 void insert_cell(
size_t i,
size_t j,
Cell< Cell_Type > && v,
bool check_bounds,
bool check_exists);
183 void insert_cell(
size_t i,
size_t j, Cell_Type v,
bool check_bounds,
bool check_exists);
186 size_t i0,
size_t j0,
size_t i1,
size_t j1,
bool check_bounds = true,
188 int * report =
nullptr
197 void swap_rows(
size_t i0,
size_t i1,
bool check_bounds = true);
198 void swap_cols(
size_t j0,
size_t j1,
bool check_bounds = true);
213 void print(const
char * fmt =
nullptr, ...) const;
222 BArray<Cell_Type,Data_Type>& operator+=(const Cell_Type &
rhs);
225 BArray<Cell_Type,Data_Type>& operator-=(const Cell_Type &
rhs);
227 BArray<Cell_Type,Data_Type>& operator/=(const Cell_Type &
rhs);
228 BArray<Cell_Type,Data_Type>& operator*=(const Cell_Type &
rhs);
Baseline class for binary arrays.
size_t nnozero() const noexcept
void print(const char *fmt=nullptr,...) const
void swap_rows(size_t i0, size_t i1, bool check_bounds=true)
bool is_dense() const noexcept
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(BArray< Cell_Type, Data_Type > &&x) noexcept
Move operator.
void out_of_range(size_t i, size_t j) const
BArray(const BArray< Cell_Type, Data_Type > &Array_, bool copy_data=false)
Copy constructor.
Cell< Cell_Type > default_val() const
bool operator==(const BArray< Cell_Type, Data_Type > &Array_)
void swap_cols(size_t j0, size_t j1, bool check_bounds=true)
void zero_col(size_t j, bool check_bounds=true)
const Data_Type & D() const
const Data_Type * D_ptr() const
void zero_row(size_t i, bool check_bounds=true)
void print_n(size_t nrow, size_t ncol, const char *fmt=nullptr,...) const
void resize(size_t N_, size_t M_)
void clear(bool hard=true)
void toggle_lock(size_t i, size_t j, bool check_bounds=true)
const Col_type< Cell_Type > & col(size_t i, bool check_bounds=true) const
void rm_cell(size_t i, size_t j, bool check_bounds=true, bool check_exists=true)
void toggle_cell(size_t i, size_t j, bool check_bounds=true, int check_exists=EXISTS::UKNOWN)
BArray< Cell_Type, Data_Type > & operator=(BArray< Cell_Type, Data_Type > &&x) noexcept
Move assignment.
void insert_cell(size_t i, size_t j, const Cell< Cell_Type > &v, bool check_bounds, bool check_exists)
size_t ncol() const noexcept
BArray< Cell_Type, Data_Type > & operator=(const BArray< Cell_Type, Data_Type > &Array_)
Assignment constructor.
Cell_Type get_cell(size_t i, size_t j, bool check_bounds=true) const
bool is_empty(size_t i, size_t j, bool check_bounds=true) const
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)
Entries< Cell_Type > get_entries() const
Get the edgelist.
void set_data(Data_Type *data_, bool delete_data_=false)
Set the data object.
const Row_type< Cell_Type > & row(size_t i, bool check_bounds=true) const
std::vector< Cell_Type > get_col_vec(size_t i, bool check_bounds=true) const
size_t nrow() const noexcept
void get_col_vec(std::vector< Cell_Type > *x, size_t i, bool check_bounds=true) const
std::vector< Cell_Type > get_row_vec(size_t i, bool check_bounds=true) const
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(size_t N_, size_t M_)
Empty array.
void get_row_vec(std::vector< Cell_Type > *x, size_t i, bool check_bounds=true) const
Entries in BArray. For now, it only has two members:
A wrapper class to store source, target, val from a BArray object.
Data_Type &&counter_ data(std::move(counter_.data))
Data_Type &&counter_ noexcept
Data_Type Counter_fun_type< Array_Type, Data_Type > Hasher_fun_type< Array_Type, Data_Type > Data_Type data_
Integer constants used to specify which cell should be check.
Integer constants used to specify which cell should be check to exist or not.
Map< size_t, Cell< Cell_Type > > Row_type
Map< size_t, Cell< Cell_Type > * > Col_type