public void EndgueltigenZyklusBestimmenTest() { int[] zahlensysteme = new int[] { 2, 2 * 2, 2 * 2 * 2, 2 * 2 * 2 * 2, 2 * 2 * 2 * 2 * 2, 2 * 2 * 2 * 2 * 2 * 2, 3, 3 * 3, 3 * 3 * 3, 3 * 3 * 3 * 3, 3 * 3 * 3 * 3 * 3, 3 * 3 * 3 * 3 * 3 * 3, 5, 5 * 5, 5 * 5 * 5, 5 * 5 * 5 * 5, 7, 7 * 7, 7 * 7 * 7, 7 * 7 * 7 * 7, 11, 11 * 11, 11 * 11 * 11, 13, 13 * 13, 13 * 13 * 13, }; int a = 29; int b = 31; // 3, 4, 5, 7, 11, 13, 17, 19, .. 23 // int[] zahlensysteme = new int[] { 9, 16, 25, 49, 121, 169, 289, 361 }; // int a = 29; // int b = 31; Zyklus actual = FermatExtended.EndgueltigenZyklusBestimmen(new BigInteger(a * b), zahlensysteme); SortZyklus(ref actual, a * b); Assert.IsTrue(actual.NumberOfElements == 45); Assert.IsTrue(actual.ZyklusSumme == 2310); }
public void TrefferBestimmenGrobTest() { int n = 499 * 41; List <Zyklus> result = FermatExtended.TrefferBestimmen(n, new int[] { 10 }); List <FermatExtended.MddPaarImZahlensystem> paare = FermatExtended.mdPaareBestimmen(n, new int[] { 10 }); List <Tuple <int, int, int> > vergleichsliste = new List <Tuple <int, int, int> >(); int m = (int)Math.Sqrt(n) + 1; FermatExtended.MddPaarImZahlensystem aktuellesPaar = paare[0]; for (int i = 0; i < (aktuellesPaar.Zahlensystem); i++) { int dd = m * m - n; if (aktuellesPaar.MddPaar.Exists(x => ((x.Item1 == m % aktuellesPaar.Zahlensystem) && (x.Item2 == dd % aktuellesPaar.Zahlensystem)))) { vergleichsliste.Add(new Tuple <int, int, int>(m % aktuellesPaar.Zahlensystem, dd % aktuellesPaar.Zahlensystem, i)); } m++; } vergleichsliste.Add(new Tuple <int, int, int>(0, 0, aktuellesPaar.Zahlensystem + vergleichsliste[0].Item3)); Zyklus aktuellerZyklus = result[0]; for (int i = 0; i < aktuellerZyklus.NumberOfElements; i++) { Assert.IsTrue(vergleichsliste[i].Item3 == aktuellerZyklus.Elemente[i]); } }
public void BestimmeOffsetZahlenZweierZyklenTest3() { int a = 121; int b = 15; Tuple <long, long> actual = Zyklus.BestimmeOffsetZahlenZweierZyklen(a, b); Assert.IsTrue(((actual.Item1 * a) % (actual.Item2 * b)) == 1); }
// //You can use the following additional attributes as you write your tests: // //Use ClassInitialize to run code before running the first test in the class //[ClassInitialize()] //public static void MyClassInitialize(TestContext testContext) //{ //} // //Use ClassCleanup to run code after all tests in a class have run //[ClassCleanup()] //public static void MyClassCleanup() //{ //} // //Use TestInitialize to run code before running each test //[TestInitialize()] //public void MyTestInitialize() //{ //} // //Use TestCleanup to run code after each test has run //[TestCleanup()] //public void MyTestCleanup() //{ //} // #endregion static private void SortZyklus(ref Zyklus zyklus, int size) { for (int i = 0; i < zyklus.NumberOfElements; i++) { if (zyklus.Elemente[i] < 0) { zyklus.Elemente[i] += size; } } zyklus.Sort(); }
public void ZyklusIstVerkuerzbarTest2() { const int zyklusSumme = 4; Zyklus zyklus = new Zyklus(zyklusSumme, new long[] { 0, 2 }); long[] neu = new long[] { 0 }; // da Referenztyp Zyklus.ZyklusVerkuerzen(ref zyklus); for (int i = 0; i < neu.Length; i++) { Assert.IsTrue(zyklus.Elemente[i] == neu[i]); } Assert.IsTrue(zyklus.ZyklusSumme == (zyklusSumme / 2)); }
public void ZyklusIstNichtEchtVerkuerzbarTest() { const int zyklusSumme = 13; Zyklus zyklus = new Zyklus(zyklusSumme, new long[] { 0, 2, 5, 8, 10 }); long[] neu = new long[] { 0, 2, 5, 8, 10 }; // da Referenztyp Zyklus.ZyklusVerkuerzen(ref zyklus); for (int i = 0; i < neu.Length; i++) { Assert.IsTrue(zyklus.Elemente[i] == neu[i]); } Assert.IsTrue(zyklus.ZyklusSumme == zyklusSumme); }
public void BestimmeOffsetZahlenZweierZyklenTest7() { int b = 197; for (int a = 501; a < 800; a++) { // Überspringe Teiler if (a % b == 0) { continue; } Tuple <long, long> actual = Zyklus.BestimmeOffsetZahlenZweierZyklen(a, b); Assert.IsTrue(((actual.Item1 * a) % (actual.Item2 * b)) == 1); } }
public void VerschmelzeZyklenTest1() { Zyklus zyklusA = new Zyklus(2, new long[] { 1, 2 }); Zyklus zyklusB = new Zyklus(3, new long[] { 1, 2 }); Zyklus expected = new Zyklus(6, new long[] { 1, 2, 4, 5 }); Zyklus actual = Zyklus.VerschmelzeZyklen(zyklusA, zyklusB); Assert.IsTrue(expected.NumberOfElements == actual.NumberOfElements); SortZyklus(ref actual, 6); for (int i = 0; i < expected.NumberOfElements; i++) { Assert.IsTrue(actual.Exists(x => x == expected.Elemente[i])); } }
public void VerschmelzeZyklenTest2() { Zyklus zyklusA = new Zyklus(3, new long[] { 1, 2 }); Zyklus zyklusB = new Zyklus(5, new long[] { 1, 2, 5 }); Zyklus expected = new Zyklus(15, new long[] { 1, 2, 5, 7, 10, 11 }); Zyklus actual = Zyklus.VerschmelzeZyklen(zyklusA, zyklusB); Assert.IsTrue(expected.NumberOfElements == actual.NumberOfElements); SortZyklus(ref actual, 15); for (int i = 0; i < expected.NumberOfElements; i++) { // Bedenken, dass für den Zyklus der Länge 15 gilt: -1 == 14 Assert.IsTrue(actual.Exists(x => x == expected.Elemente[i])); } }