1
0
mirror of https://github.com/biergaizi/codecrypt synced 2024-06-26 00:38:16 +00:00
codecrypt/src/ios.cpp

66 lines
1.8 KiB
C++
Raw Normal View History

2012-04-07 13:15:13 +00:00
2012-11-05 21:45:35 +00:00
/*
* This file is part of Codecrypt.
*
2016-04-17 13:47:47 +00:00
* Copyright (C) 2013-2016 Mirek Kratochvil <exa.exa@gmail.com>
*
2012-11-05 21:45:35 +00:00
* Codecrypt is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Codecrypt is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Codecrypt. If not, see <http://www.gnu.org/licenses/>.
*/
2012-12-25 13:39:39 +00:00
#include "ios.h"
2012-04-07 13:15:13 +00:00
2013-06-21 18:35:40 +00:00
std::ostream& operator<< (std::ostream&o, const polynomial& p)
2012-04-07 13:15:13 +00:00
{
2013-05-18 07:21:49 +00:00
o << "polynomial degree " << p.degree() << ": ";
2012-04-07 13:15:13 +00:00
for (int i = 0, e = p.degree(); i <= e; ++i) o << p[i] << ' ';
2013-06-21 18:35:40 +00:00
o << std::endl;
2012-04-07 13:15:13 +00:00
return o;
}
2013-06-21 18:35:40 +00:00
std::ostream& operator<< (std::ostream&o, const permutation& p)
2012-04-07 13:15:13 +00:00
{
2013-05-18 07:21:49 +00:00
o << "permutation over " << p.size() << " elements: ";
2012-04-07 13:15:13 +00:00
for (uint i = 0; i < p.size(); ++i) o << p[i] << ' ';
2013-06-21 18:35:40 +00:00
o << std::endl;
2012-04-07 13:15:13 +00:00
return o;
}
2013-06-21 18:35:40 +00:00
std::ostream& operator<< (std::ostream&o, const gf2m& f)
2012-04-07 13:15:13 +00:00
{
2013-06-21 18:35:40 +00:00
o << "GF(2^" << f.m << ") of " << f.n << " elements, modulus " << f.poly << std::endl;
2012-04-07 13:15:13 +00:00
return o;
}
2013-06-21 18:35:40 +00:00
std::ostream& operator<< (std::ostream&o, const matrix& m)
2012-04-07 13:15:13 +00:00
{
uint i, j, h, w;
h = m.height();
w = m.width();
2013-06-21 18:35:40 +00:00
o << "binary " << h << "x" << w << " matrix:" << std::endl;
2012-04-07 13:15:13 +00:00
for (i = 0; i < h; ++i) {
for (j = 0; j < w; ++j) o << m[j][i];
2013-06-21 18:35:40 +00:00
o << std::endl;
2012-04-07 13:15:13 +00:00
}
return o;
}
2013-06-21 18:35:40 +00:00
std::ostream& operator<< (std::ostream&o, const bvector& v)
2012-04-07 13:15:13 +00:00
{
2013-05-18 07:21:49 +00:00
o << "vector of " << v.size() << " elements: ";
2012-05-15 12:03:56 +00:00
for (uint i = 0, e = v.size(); i < e; ++i) o << v[i];
2013-06-21 18:35:40 +00:00
o << std::endl;
2012-04-07 13:15:13 +00:00
return o;
}