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;
117 GF2mat_sparse to_sparse(
bool transpose =
false)
const;
126 void from_sparse(
const GF2mat_sparse &mat,
bool transpose =
false);
184 GF2mat(
const GF2mat_sparse &X);
190 GF2mat(
const GF2mat_sparse &X,
int m1,
int n1,
int m2,
int n2);
200 GF2mat(
const GF2mat_sparse &X,
const ivec &columns);
209 GF2mat(
const bvec &x,
bool is_column =
true);
215 void set_size(
int m,
int n,
bool copy =
false);
218 GF2mat_sparse sparsify()
const;
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);
420 Mat<unsigned char> data;
424 static const unsigned char shift_divisor = 3;
428 static const unsigned char rem_mask = (1 << shift_divisor) - 1;
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)));
517 #endif // #ifndef GF2MAT_H int rank(const Mat< T > &m, double tol=-1.0)
Calculate the rank of matrix m.
ivec num_nlist
Weight of each column n.
int max_num_m
Maximum weight of rows.
ivec num_mlist
Weight of each row m.
void set(int i, int j, bin s)
Set element i,j to s (0 or 1)
Definition of classes for the IT++ file format.
Class for dense GF(2) matrices.
int rows() const
Get number of rows.
bin get(int i, int j) const
Getting element.
GF2mat mult_trans(const GF2mat &X, const GF2mat &Y)
Multiplication X*Y' where X and Y are GF(2) matrices.
imat nlist
List of integer coordinates in the n direction with non-zero entries.
std::ostream & operator<<(std::ostream &output, const bin &inbin)
Output stream of bin.
bool data_ok
Flag indicating that "alist" matrix data are properly set.
GF2mat gf2dense_eye(int m)
GF(2) Identity matrix.
#define it_assert_debug(t, s)
Abort if t is not true and NDEBUG is not defined.
Sparse Matrix Class Definitions.
int M
Size of the matrix: M rows x N columns.
Matrix Class Definitions.
int cols() const
Get number of columns.
GF2mat operator+(const GF2mat &X, const GF2mat &Y)
GF(2) matrix addition.
The IT++ file format reading and writing class.
imat mlist
List of integer coordinates in the m direction with non-zero entries.
The IT++ file format reading class.
GF2mat operator*(const GF2mat &X, const GF2mat &Y)
GF(2) matrix multiplication.
Sparse_Mat< bin > GF2mat_sparse
Sparse GF(2) matrix.
Binary arithmetic (boolean) class.
void transpose(const Mat< T > &m, Mat< T > &out)
Transposition of the matrix m returning the transposed matrix in out.
void addto_element(int i, int j, bin s)
Add s (0 or 1) to element (i,j)
int N
Size of the matrix: M rows x N columns.
GF2mat_sparse_alist()
Default constructor.
Sparse_Vec< bin > GF2vec_sparse
Sparse GF(2) vector.
Sparse Vector Class definitions.
std::istream & operator>>(std::istream &input, bin &outbin)
Input stream of bin.
Parameterized "alist" representation of sparse GF(2) matrix.
int max_num_n
Maximum weight of columns.
bin operator()(int i, int j) const
Getting element.
Mat< bin > bmat
bin matrix
Templated Vector Class Definitions.