// GaussBin.cpp : Defines the entry point for the console application. // #include #include #include #include #include #include inline int GET(unsigned long **mas, int i, int j) { return ((mas[i][j>>5]>>(j&31))&1); } inline int PUT(unsigned long **mas, int i, int j, int k) { return mas[i][j>>5]=(k)?(mas[i][j>>5]|(1<<(j&31))):(mas[i][j>>5]&((1<<(j&31))^-1)); } void GaussBin_Elimination(char * inputname, char * outputname) { FILE * in=fopen(inputname,"rb"); long m, n, i, j, k, l, cols, sum, old, rem=0; fscanf(in,"%ld %ld", &n, &m); cols=1+(n>>5); unsigned long ** mas=new unsigned long*[m]; for(i=0; i>5]>>(j&31))&1) // #define PUT(i,j,k) mas[i][j>>5]=(k)?(mas[i][j>>5]|(1<<(j&31))):(mas[i][j>>5]&((1<<(j&31))^-1)) // Read the input matrix m*n for(i=0; i12) { printf("The number of solutions is too many (2^%ld) ... trancated to 2^12!\n", sum); sum=12; // too many solutions!!! } fprintf(out,"%ld\n", (1<>j)&1; // calculate the rest variables here for(j=0; j=0) { for(l=k=0; l \n" "\n" " - description:\n" "M N - first line contains the matrix size M*N\n" " M denotes the number of (r^2 mod N) - numbers\n" " N denotes the factor base size\n" "x11 x12 ... x1N - the integer nonnegative values of the matrix \n" "x21 x22 ... x2N will be taken modulo 2, and then the Gaussian\n" " ... elimination algorithm will be performed.\n" "xM1 xM2 ... xMN\n" "\n" " - description:\n" "R - the number of solutions. If there are a lot of solutions, then\n" " it will be truncated to 2^12 solutions.\n" "s11 s12 ... s1M - each line contains a solution vector. i.e. if\n" "s21 s22 ... s2M we consider solution i, then si1, si2, ..., siM \n" " ... denote the correspondent rows from the input_file \n" "sR1 sR2 ... sRM that we need to sum in order to get (0) modulo 2.\n" "\n" "Cryptology course. Information Technology (c)2003.\n"); } else { GaussBin_Elimination(argv[1], argv[2]); } return 0; }