1 #ifndef BARRY_BARRAYDENSE_BONES_HPP
2 #define BARRY_BARRAYDENSE_BONES_HPP 1
4 template<
typename Cell_Type,
typename Data_Type>
7 template<
typename Cell_Type,
typename Data_Type>
10 template<
typename Cell_Type,
typename Data_Type>
13 template<
typename Cell_Type,
typename Data_Type>
16 template<
typename Cell_Type,
typename Data_Type>
19 template<
typename Cell_Type,
typename Data_Type>
32 template <
typename Cell_Type =
bool,
typename Data_Type =
bool>
45 std::vector< Cell_Type > el;
46 std::vector< Cell_Type > el_rowsums;
47 std::vector< Cell_Type > el_colsums;
48 Data_Type *
data =
nullptr;
49 bool delete_data =
false;
51 static Cell_Type Cell_default;
52 static const bool dense =
true;
79 BArrayDense() : N(0u), M(0u), el(0u), el_rowsums(0u), el_colsums(0u) {};
82 BArrayDense (
size_t N_,
size_t M_, Cell_Type value =
static_cast<Cell_Type
>(0)) :
83 N(N_), M(M_), el(N_ * M_, value),
84 el_rowsums(N_, static_cast<Cell_Type>(value * M_)), el_colsums(M_, static_cast<Cell_Type>(value * N_)) {};
90 const std::vector< size_t > & source,
91 const std::vector< size_t > & target,
92 const std::vector< Cell_Type > & value,
99 const std::vector< size_t > & source,
100 const std::vector< size_t > & target,
134 const Data_Type *
D_ptr()
const;
136 const Data_Type &
D()
const;
142 Cell_Type
get_cell(
size_t i,
size_t j,
bool check_bounds =
true)
const;
143 std::vector< Cell_Type >
get_col_vec(
size_t i,
bool check_bounds =
true)
const;
144 std::vector< Cell_Type >
get_row_vec(
size_t i,
bool check_bounds =
true)
const;
145 void get_col_vec(std::vector< Cell_Type > * x,
size_t i,
bool check_bounds =
true)
const;
146 void get_row_vec(std::vector< Cell_Type > * x,
size_t i,
bool check_bounds =
true)
const;
173 bool is_empty(
size_t i,
size_t j,
bool check_bounds =
true)
const;
190 BArrayDense<Cell_Type,Data_Type> & operator+=(const std::pair<
size_t,
size_t> & coords);
191 BArrayDense<Cell_Type,Data_Type> & operator-=(const std::pair<
size_t,
size_t> & coords);
192 BArrayDenseCell<Cell_Type,Data_Type> operator()(
size_t i,
size_t j,
bool check_bounds = true);
193 const Cell_Type operator()(
size_t i,
size_t j,
bool check_bounds = true) const;
195 void rm_cell(
size_t i,
size_t j,
bool check_bounds = true,
bool check_exists = true);
197 void insert_cell(
size_t i,
size_t j, const
Cell< Cell_Type > & v,
bool check_bounds,
bool);
199 void insert_cell(
size_t i,
size_t j, Cell_Type v,
bool check_bounds,
bool);
202 size_t i0,
size_t j0,
size_t i1,
size_t j1,
bool check_bounds = true,
204 int * report =
nullptr
213 void swap_rows(
size_t i0,
size_t i1,
bool check_bounds = true);
214 void swap_cols(
size_t j0,
size_t j1,
bool check_bounds = true);
216 void zero_row(
size_t i,
bool check_bounds = true);
217 void zero_col(
size_t j,
bool check_bounds = true);
221 void clear(
bool hard = true);
222 void resize(
size_t N_,
size_t M_);
229 void print(const
char * fmt =
nullptr, ...) const;
258 const std::vector< Cell_Type > &
get_data()
const;
259 const Cell_Type
rowsum(
size_t i)
const;
260 const Cell_Type
colsum(
size_t i)
const;
Baseline class for binary arrays.
Cell< Cell_Type > default_val() const
std::vector< Cell_Type > get_col_vec(size_t i, bool check_bounds=true) const
void zero_row(size_t i, bool check_bounds=true)
bool is_empty(size_t i, size_t j, bool check_bounds=true) const
BArrayDense< Cell_Type, Data_Type > & operator=(const BArrayDense< Cell_Type, Data_Type > &Array_)
Assignment constructor.
bool operator==(const BArrayDense< Cell_Type, Data_Type > &Array_)
void swap_cols(size_t j0, size_t j1, bool check_bounds=true)
const Cell_Type rowsum(size_t i) const
size_t ncol() const noexcept
const std::vector< Cell_Type > & get_data() const
void print(const char *fmt=nullptr,...) const
size_t nrow() const noexcept
size_t nnozero() const noexcept
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 insert_cell(size_t i, size_t j, const Cell< Cell_Type > &v, bool check_bounds, bool)
BArrayDenseCol< Cell_Type, Data_Type > & col(size_t j, bool check_bounds=true)
void rm_cell(size_t i, size_t j, bool check_bounds=true, bool check_exists=true)
void clear(bool hard=true)
void set_data(Data_Type *data_, bool delete_data_=false)
Set the data object.
std::vector< Cell_Type > get_row_vec(size_t i, bool check_bounds=true) const
Entries< Cell_Type > get_entries() const
Get the edgelist.
void out_of_range(size_t i, size_t j) const
void toggle_cell(size_t i, size_t j, bool check_bounds=true, int check_exists=EXISTS::UKNOWN)
void zero_col(size_t j, bool check_bounds=true)
void swap_rows(size_t i0, size_t i1, bool check_bounds=true)
BArrayDense(size_t N_, size_t M_, Cell_Type value=static_cast< Cell_Type >(0))
Empty array.
bool is_dense() const noexcept
BArrayDenseRow< Cell_Type, Data_Type > & row(size_t i, bool check_bounds=true)
void toggle_lock(size_t i, size_t j, bool check_bounds=true)
const Cell_Type colsum(size_t i) const
BArrayDense()
Zero-size array.
void resize(size_t N_, size_t M_)
Cell_Type get_cell(size_t i, size_t j, 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.