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)));
517 #endif // #ifndef GF2MAT_H