std namespace cleaning
This commit is contained in:
		
							parent
							
								
									79c4ea8e93
								
							
						
					
					
						commit
						36b68d90c1
					
				| 
						 | 
					@ -21,8 +21,6 @@
 | 
				
			||||||
#include <fstream>
 | 
					#include <fstream>
 | 
				
			||||||
#include <vector>
 | 
					#include <vector>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
using namespace std;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static inline uint bytes (uint bits)
 | 
					static inline uint bytes (uint bits)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return (bits >> 3) + ( (bits & 7) ? 1 : 0);
 | 
						return (bits >> 3) + ( (bits & 7) ? 1 : 0);
 | 
				
			||||||
| 
						 | 
					@ -30,13 +28,14 @@ static inline uint bytes (uint bits)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void arcfour_rng::seed (uint bits, bool quick)
 | 
					void arcfour_rng::seed (uint bits, bool quick)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	vector<byte> s;
 | 
						std::vector<byte> s;
 | 
				
			||||||
	ifstream f;
 | 
						std::ifstream f;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	uint b = bytes (bits);
 | 
						uint b = bytes (bits);
 | 
				
			||||||
	if (b > 256) b = 256;
 | 
						if (b > 256) b = 256;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	f.open (quick ? "/dev/urandom" : "/dev/random", ios::in | ios::binary);
 | 
						f.open (quick ? "/dev/urandom" : "/dev/random",
 | 
				
			||||||
 | 
						        std::ios::in | std::ios::binary);
 | 
				
			||||||
	s.resize (b);
 | 
						s.resize (b);
 | 
				
			||||||
	for (uint i = 0; i < b; ++i) f >> s[i];
 | 
						for (uint i = 0; i < b; ++i) f >> s[i];
 | 
				
			||||||
	f.close();
 | 
						f.close();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										24
									
								
								src/ios.cpp
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								src/ios.cpp
									
									
									
									
									
								
							| 
						 | 
					@ -18,48 +18,46 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "ios.h"
 | 
					#include "ios.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
using namespace std;
 | 
					std::ostream& operator<< (std::ostream&o, const polynomial& p)
 | 
				
			||||||
 | 
					 | 
				
			||||||
ostream& operator<< (ostream&o, const polynomial& p)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	o << "polynomial degree " << p.degree() << ": ";
 | 
						o << "polynomial degree " << p.degree() << ": ";
 | 
				
			||||||
	for (int i = 0, e = p.degree(); i <= e; ++i) o << p[i] << ' ';
 | 
						for (int i = 0, e = p.degree(); i <= e; ++i) o << p[i] << ' ';
 | 
				
			||||||
	o << endl;
 | 
						o << std::endl;
 | 
				
			||||||
	return o;
 | 
						return o;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ostream& operator<< (ostream&o, const permutation& p)
 | 
					std::ostream& operator<< (std::ostream&o, const permutation& p)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	o << "permutation over " << p.size() << " elements: ";
 | 
						o << "permutation over " << p.size() << " elements: ";
 | 
				
			||||||
	for (uint i = 0; i < p.size(); ++i) o << p[i] << ' ';
 | 
						for (uint i = 0; i < p.size(); ++i) o << p[i] << ' ';
 | 
				
			||||||
	o << endl;
 | 
						o << std::endl;
 | 
				
			||||||
	return o;
 | 
						return o;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ostream& operator<< (ostream&o, const gf2m& f)
 | 
					std::ostream& operator<< (std::ostream&o, const gf2m& f)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	o << "GF(2^" << f.m << ") of " << f.n << " elements, modulus " << f.poly << endl;
 | 
						o << "GF(2^" << f.m << ") of " << f.n << " elements, modulus " << f.poly << std::endl;
 | 
				
			||||||
	return o;
 | 
						return o;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ostream& operator<< (ostream&o, const matrix& m)
 | 
					std::ostream& operator<< (std::ostream&o, const matrix& m)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	uint i, j, h, w;
 | 
						uint i, j, h, w;
 | 
				
			||||||
	h = m.height();
 | 
						h = m.height();
 | 
				
			||||||
	w = m.width();
 | 
						w = m.width();
 | 
				
			||||||
	o << "binary " << h << "x" << w << " matrix:" << endl;
 | 
						o << "binary " << h << "x" << w << " matrix:" << std::endl;
 | 
				
			||||||
	for (i = 0; i < h; ++i) {
 | 
						for (i = 0; i < h; ++i) {
 | 
				
			||||||
		for (j = 0; j < w; ++j) o << m[j][i];
 | 
							for (j = 0; j < w; ++j) o << m[j][i];
 | 
				
			||||||
		o << endl;
 | 
							o << std::endl;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return o;
 | 
						return o;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ostream& operator<< (ostream&o, const bvector& v)
 | 
					std::ostream& operator<< (std::ostream&o, const bvector& v)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	o << "vector of " << v.size() << " elements: ";
 | 
						o << "vector of " << v.size() << " elements: ";
 | 
				
			||||||
	for (uint i = 0, e = v.size(); i < e; ++i) o << v[i];
 | 
						for (uint i = 0, e = v.size(); i < e; ++i) o << v[i];
 | 
				
			||||||
	o << endl;
 | 
						o << std::endl;
 | 
				
			||||||
	return o;
 | 
						return o;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -157,12 +157,13 @@ void polynomial::generate_random_irreducible (uint s, gf2m&fld, prng& rng)
 | 
				
			||||||
		item (rng.random (s) ) = rng.random (fld.n);
 | 
							item (rng.random (s) ) = rng.random (fld.n);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool polynomial::compute_square_root_matrix (vector<polynomial>&r, gf2m&fld)
 | 
					bool polynomial::compute_square_root_matrix (std::vector<polynomial>&r,
 | 
				
			||||||
 | 
					                                             gf2m&fld)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	// step 1, generate a square matrix of squares mod poly.
 | 
						// step 1, generate a square matrix of squares mod poly.
 | 
				
			||||||
	int d = degree();
 | 
						int d = degree();
 | 
				
			||||||
	if (d < 0) return false;
 | 
						if (d < 0) return false;
 | 
				
			||||||
	vector<polynomial>l;
 | 
						std::vector<polynomial>l;
 | 
				
			||||||
	l.resize (d);
 | 
						l.resize (d);
 | 
				
			||||||
	polynomial col, t;
 | 
						polynomial col, t;
 | 
				
			||||||
	for (int i = 0; i < d; ++i) {
 | 
						for (int i = 0; i < d; ++i) {
 | 
				
			||||||
| 
						 | 
					@ -275,7 +276,7 @@ void polynomial::square (gf2m&fld)
 | 
				
			||||||
	mult (a, fld);
 | 
						mult (a, fld);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void polynomial::sqrt (vector<polynomial>& sqInv, gf2m&fld)
 | 
					void polynomial::sqrt (std::vector<polynomial>& sqInv, gf2m&fld)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	polynomial a = *this;
 | 
						polynomial a = *this;
 | 
				
			||||||
	clear();
 | 
						clear();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -58,7 +58,7 @@ public:
 | 
				
			||||||
	void inv (polynomial&, gf2m&);
 | 
						void inv (polynomial&, gf2m&);
 | 
				
			||||||
	void make_monic (gf2m&);
 | 
						void make_monic (gf2m&);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void sqrt (vector<polynomial>&, gf2m&);
 | 
						void sqrt (std::vector<polynomial>&, gf2m&);
 | 
				
			||||||
	polynomial gcd (polynomial, gf2m&);
 | 
						polynomial gcd (polynomial, gf2m&);
 | 
				
			||||||
	void ext_euclid (polynomial&, polynomial&, polynomial&, gf2m&, int);
 | 
						void ext_euclid (polynomial&, polynomial&, polynomial&, gf2m&, int);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,7 +19,6 @@
 | 
				
			||||||
#include "qd_utils.h"
 | 
					#include "qd_utils.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <vector>
 | 
					#include <vector>
 | 
				
			||||||
using namespace std;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * we count on that all integers are sufficiently large.
 | 
					 * we count on that all integers are sufficiently large.
 | 
				
			||||||
| 
						 | 
					@ -27,7 +26,7 @@ using namespace std;
 | 
				
			||||||
 * consisted only from {0,1}^n, and we don't usually have codes of this size.
 | 
					 * consisted only from {0,1}^n, and we don't usually have codes of this size.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void fwht (vector<int> x, vector<int>&r)
 | 
					static void fwht (std::vector<int> x, std::vector<int>&r)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int bs, s;
 | 
						int bs, s;
 | 
				
			||||||
	s = x.size();
 | 
						s = x.size();
 | 
				
			||||||
| 
						 | 
					@ -51,7 +50,9 @@ static void fwht (vector<int> x, vector<int>&r)
 | 
				
			||||||
 * this multiple times.
 | 
					 * this multiple times.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
void fwht_dyadic_multiply (const bvector& a, const bvector& b, bvector& out,
 | 
					void fwht_dyadic_multiply (const bvector& a, const bvector& b, bvector& out,
 | 
				
			||||||
                           vector<int>&t, vector<int>&A, vector<int>&B)
 | 
					                           std::vector<int>&t,
 | 
				
			||||||
 | 
					                           std::vector<int>&A,
 | 
				
			||||||
 | 
					                           std::vector<int>&B)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	uint i;
 | 
						uint i;
 | 
				
			||||||
| 
						 | 
					@ -109,7 +110,7 @@ bool qd_to_right_echelon_form (std::vector<std::vector<bvector> >&mat)
 | 
				
			||||||
	bvector tmp;
 | 
						bvector tmp;
 | 
				
			||||||
	tmp.resize (bs);
 | 
						tmp.resize (bs);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	vector<int> c1, c2, c3;
 | 
						std::vector<int> c1, c2, c3;
 | 
				
			||||||
	c1.resize (bs);
 | 
						c1.resize (bs);
 | 
				
			||||||
	c2.resize (bs);
 | 
						c2.resize (bs);
 | 
				
			||||||
	c3.resize (bs);
 | 
						c3.resize (bs);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue