Newer
Older
* Copyright (c) 2015-2016, Luca Fulchir<luca@fulchir.it>, All rights reserved.
*
* This file is part of "libRaptorQ".
*
* libRaptorQ 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.
*
* libRaptorQ 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* and a copy of the GNU Lesser General Public License
* along with libRaptorQ. If not, see <http://www.gnu.org/licenses/>.
*/
#include "RaptorQ/v1/common.hpp"
#include "RaptorQ/v1/multiplication.hpp"
#include "RaptorQ/v1/table2.hpp"
namespace Impl {
class RAPTORQ_LOCAL Tuple
{
// d 1-30 LT-degree of encoded symbol
// a 0-(W-1)
// b 0-(W-1)
// d1 PI-degree of encoded symbol (2 or 3)
// a1 0-(P1-1)
// b1 0-(P1-1)
public:
uint16_t d, a, b, d1, a1, b1; // great names. thanks rfc6330!
};
class RAPTORQ_API Parameters
{
public:
uint16_t Deg (const uint32_t v) const;
Tuple tuple (const uint32_t ISI) const;
std::vector<uint16_t> get_idxs (const uint32_t ISI) const;
uint16_t K_padded, S, H, W, L, P, P1, U, B; // RFC 6330, pg 22
uint16_t J;
private:
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
{
public:
Octet () {}
Octet (const uint8_t val) : data(val) {}
explicit operator uint8_t() const { return data; }
Octet& operator-= (const Octet a)
{
data ^= a.data;
return *this;
}
friend Octet operator- (Octet lhs, const Octet rhs)
{
lhs.data ^= rhs.data;
return lhs;
}
Octet& operator+= (const Octet a)
{
data ^= a.data;
return *this;
}
friend Octet operator+ (Octet lhs, const Octet rhs)
{
lhs.data ^= rhs.data;
return lhs;
}
// xor, addition, subtraction... they're the same to me...
Octet& operator^= (const Octet &a)
{
data ^= a.data;
return *this;
}
friend Octet operator^ (Octet lhs, const Octet rhs)
{
lhs.data ^= rhs.data;
return lhs;
}
Octet& operator*= (const Octet a)
{
if (data != 0 && a.data != 0) {
oct_log[a.data - 1]];
} else {
data = 0;
}
return *this;
}
friend Octet operator* (Octet lhs, const Octet rhs)
{
if (lhs.data != 0 && rhs.data != 0) {
oct_log[rhs.data - 1]];
} else {
lhs.data = 0;
}
return lhs;
}
Octet& operator/= (const Octet a)
{
if (a.data != 0 && data != 0) {
friend Octet operator/ (Octet lhs, const Octet rhs)
{
lhs /= rhs;
return lhs;
}
return Octet (RaptorQ__v1::Impl::oct_exp[255 - oct_log[data - 1]]);
bool operator== (const Octet a) const
{ return data == a.data; }
bool operator!= (const Octet a) const
{ return data != a.data; }
friend std::ostream &operator<< (std::ostream &os, const Octet m) {
// used to print
os << static_cast<uint32_t> (m.data);
inline uint8_t abs (Octet x) { return static_cast<uint8_t> (x); }
} // namespace Impl
} // namespace RaptorQ
namespace Eigen {
template<>
struct NumTraits<RaptorQ__v1::Impl::Octet> : NumTraits<uint8_t> {};