00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _MATRIX_H
00022 #define _MATRIX_H
00023
00024 #define BITS_PER_LONG (8 * sizeof (unsigned long))
00025
00026 typedef struct matrix{
00027 int rown;
00028 int coln;
00029 int rwdcnt;
00030 int alloc_size;
00031 unsigned long *elem;
00032 }*binmat_t;
00033
00034 #define mat_coeff(A, i, j) (((A)->elem[(i) * A->rwdcnt + (j) / BITS_PER_LONG] >> (j % BITS_PER_LONG)) & 1)
00035
00036 #define mat_set_coeff_to_one(A, i, j) ((A)->elem[(i) * A->rwdcnt + (j) / BITS_PER_LONG] |= (1UL << ((j) % BITS_PER_LONG)))
00037 #define mat_change_coeff(A, i, j) ((A)->elem[(i) * A->rwdcnt + (j) / BITS_PER_LONG] ^= (1UL << ((j) % BITS_PER_LONG)))
00038 #define mat_set_to_zero(R) memset((R)->elem,0,(R)->alloc_size);
00039
00040
00041 binmat_t mat_ini(int rown, int coln);
00042 binmat_t mat_ini_from_string(int rown, int coln, const unsigned char * s);
00043 void mat_free(binmat_t A);
00044 binmat_t mat_copy(binmat_t A);
00045 binmat_t mat_rowxor(binmat_t A,int a, int b);
00046 int * mat_rref(binmat_t A);
00047 void mat_vec_mul(unsigned long *cR, unsigned char *x, binmat_t A);
00048 binmat_t mat_mul(binmat_t A, binmat_t B);
00049
00050 #endif
00051