public static cpolinom CreateRand(int n, int m) { cpolinom c = new cpolinom("", m); for (int i = 0; i < n; i++) c.Add(Mod(r.Next(), m)); while (c[0] == 0) c.RemoveAt(0); return c; }
private static void Fix(cpolinom p) { while (p[0] == 0 && p.Count != 0) p.RemoveAt(0); if (p.Count == 0) p.Add(0); }
public static cpolinom operator *(cpolinom a, cpolinom b) { cpolinom np = new cpolinom("", Math.Max(a.mod, b.mod)); cpolinom t; for (int i = 0; i < a.Count; i++) np.Add(a[i] * b[0]); for (int i = 1; i < b.Count; i++) { t = new cpolinom("", Math.Max(a.mod, b.mod)); for (int j = 0; j < a.Count; j++) t.Add(a[j] * b[i]); np.Add(0); np = np + t; } if (np.x.Count == 0) np.Insert(0, 0); while (np[0] == 0 && np.Count > 1) np.RemoveAt(0); return np; }