public BigGF Xor(BigGF b) { BigInteger first = _num; BigInteger second = b._num; return(new BigGF(this.Pow, first ^ second)); }
public BigGF MulInverse() { BigGF result = this; for (int i = 0; i < _pow; i++) { BigInteger num = new BigInteger(i); BigGF tmp = new BigGF(_pow, num); if (this.Mul(tmp).Num == 1) { return(tmp); } } return(result); }
public BigGF Div(BigGF b) { var res = new BigGF(_pow.IntValue(), _poly); while (res._num >= b._num) { int pow = res.GetMaxPow() - b.GetMaxPow(); var tmp = Mul(b._poly, pow); var newGF = new BigGF(_pow.IntValue(), tmp); var aaa = res + newGF; res = aaa; } return(res); }
public BigGF Mul(BigGF b) { var first = _poly; var second = b._poly; var res = new SortedDictionary <int, int>(); foreach (var pair1 in first) { foreach (var pair2 in second) { int key = pair1.Key + pair2.Key; int value = pair1.Value * pair2.Value; if (value == 1) { if (!res.ContainsKey(key)) { res.Add(key, 1); } else { res.Remove(key); } } } } var result = new BigGF(_pow.IntValue(), res); if (Math.Pow(2, result.GetMaxPow()) < _pow.IntValue()) { return(result); } else { double aaa = _pow.IntValue(); int ttt = (int)Math.Log(aaa, 2); var tmp = new BigGF(_pow, irreducible_polynomials[ttt - 1]); return(result.Div(tmp)); } }