50 #include <itpp/itexports.h>
56 #if (defined(_MSC_VER) && defined(ITPP_SHARED_LIB))
61 template class ITPP_EXPORT Sparse_Mat<bin>;
62 template class ITPP_EXPORT Sparse_Vec<bin>;
63 template class ITPP_EXPORT Mat<unsigned char>;
107 void read(
const std::string &fname);
109 void write(
const std::string &fname)
const;
209 GF2mat(
const bvec &x,
bool is_column =
true);
215 void set_size(
int m,
int n,
bool copy =
false);
221 bvec bvecify()
const;
226 inline bin get(
int i,
int j)
const;
232 inline void set(
int i,
int j,
bin s);
235 inline void addto_element(
int i,
int j,
bin s);
238 void set_col(
int j, bvec x);
241 void set_row(
int i, bvec x);
244 bool is_zero()
const;
247 void swap_rows(
int i,
int j);
250 void swap_cols(
int i,
int j);
258 void permute_rows(ivec &perm,
bool I);
267 void permute_cols(ivec &perm,
bool I);
273 GF2mat get_submatrix(
int m1,
int n1,
int m2,
int n2)
const;
282 bvec get_row(
int i)
const;
285 bvec get_col(
int j)
const;
288 double density()
const;
291 int rows()
const {
return nrows; }
294 int cols()
const {
return ncols; }
303 void add_rows(
int i,
int j);
315 int row_rank()
const;
357 ivec &P,
int rank,
int r,
int c)
const;
381 ivec &P, bvec newcol)
const;
386 void operator=(
const GF2mat &X);
389 bool operator==(
const GF2mat &X)
const;
406 friend ITPP_EXPORT std::ostream &
operator<<(std::ostream &os,
const GF2mat &X);
424 static const unsigned char shift_divisor = 3;
428 static const unsigned char rem_mask = (1 << shift_divisor) - 1;
440 ITPP_EXPORT it_file &
operator<<(it_file &f,
const GF2mat &X);
446 ITPP_EXPORT it_ifile &
operator>>(it_ifile &f, GF2mat &X);
453 ITPP_EXPORT GF2mat
operator*(
const GF2mat &X,
const GF2mat &Y);
459 ITPP_EXPORT bvec
operator*(
const GF2mat &X,
const bvec &y);
465 ITPP_EXPORT GF2mat
operator+(
const GF2mat &X,
const GF2mat &Y);
471 ITPP_EXPORT std::ostream &
operator<<(std::ostream &os,
const GF2mat &X);
483 ITPP_EXPORT GF2mat
mult_trans(
const GF2mat &X,
const GF2mat &Y);
495 data(i, (j >> shift_divisor)) ^= (1 << (j & rem_mask));
502 return (data(i, (j >> shift_divisor)) >> (j & rem_mask)) & 1;
510 data(i, (j >> shift_divisor)) |= (1 << (j & rem_mask));
512 data(i, (j >> shift_divisor)) &= (~(1 << (j & rem_mask)));
Parameterized "alist" representation of sparse GF(2) matrix.
int max_num_m
Maximum weight of rows.
int max_num_n
Maximum weight of columns.
int M
Size of the matrix: M rows x N columns.
imat mlist
List of integer coordinates in the m direction with non-zero entries.
imat nlist
List of integer coordinates in the n direction with non-zero entries.
int N
Size of the matrix: M rows x N columns.
ivec num_nlist
Weight of each column n.
GF2mat_sparse_alist()
Default constructor.
ivec num_mlist
Weight of each row m.
bool data_ok
Flag indicating that "alist" matrix data are properly set.
Class for dense GF(2) matrices.
int cols() const
Get number of columns.
void addto_element(int i, int j, bin s)
Add s (0 or 1) to element (i,j)
int rows() const
Get number of rows.
bin get(int i, int j) const
Getting element.
bin operator()(int i, int j) const
Getting element.
void set(int i, int j, bin s)
Set element i,j to s (0 or 1)
Templated sparse vector class.
Binary arithmetic (boolean) class.
The IT++ file format reading and writing class.
The IT++ file format reading class.
#define it_assert_debug(t, s)
Abort if t is not true and NDEBUG is not defined.
int rank(const Mat< T > &m, double tol=-1.0)
Calculate the rank of matrix m.
void transpose(const Mat< T > &m, Mat< T > &out)
Transposition of the matrix m returning the transposed matrix in out.
Definition of classes for the IT++ file format.
Matrix Class Definitions.
Mat< bin > bmat
bin matrix
GF2mat mult_trans(const GF2mat &X, const GF2mat &Y)
Multiplication X*Y' where X and Y are GF(2) matrices.
std::ostream & operator<<(std::ostream &output, const bin &inbin)
Output stream of bin.
GF2mat operator*(const GF2mat &X, const GF2mat &Y)
GF(2) matrix multiplication.
Sparse_Mat< bin > GF2mat_sparse
Sparse GF(2) matrix.
GF2mat gf2dense_eye(int m)
GF(2) Identity matrix.
std::istream & operator>>(std::istream &input, bin &outbin)
Input stream of bin.
Sparse_Vec< bin > GF2vec_sparse
Sparse GF(2) vector.
GF2mat operator+(const GF2mat &X, const GF2mat &Y)
GF(2) matrix addition.
Sparse Matrix Class Definitions.
Sparse Vector Class definitions.
Templated Vector Class Definitions.