Ejemplo n.º 1
0
        /// <summary>
        /// Zeigt einen Lotto Quicktipp
        /// für Österreich an.
        /// </summary>
        public void ZeigeDurchlaufen()
        {
            Algorithmus.Ausgeben("ZeigeDurchlaufen startet...", debug: true);

            var Lotto = new Lotto();

            //  ^-> macht Microsoft liebend gerne,
            //      die Objektvariable genauso zu nennen,
            //      wie die Klasse

            //Land zufällig einstellen
            Lotto.Land
                = (LottoLänder)this.Zufallsgenerator
                  .Next(System.Enum.GetValues(typeof(LottoLänder)).Length);

            //Reihenfolge zufällig einstellen...
            //Lotto.Sortiert = this.Zufallsgenerator.Next(2) == 1 ? true : false;
            //                 |---------------------------------|
            //                      ist schon true oder false
            Lotto.Sortiert = this.Zufallsgenerator.Next(2) == 1;


            //Das zufällige Land und die Zahlen
            //eines Quicktipps ausgeben.
            var Text = new System.Text.StringBuilder();

            Text.AppendLine($"Lotto Quicktipp {Lotto.Land}: {Lotto.AnzahlZahlen} aus {Lotto.HöchsteZahl}");

            //Die Anzahl der Zahlen ist bekannt, deshalb...
            //Zählschleife. Weil jede Zahl des Datenfelds
            //benötigt wird, die Spezialzählschleife...
            foreach (int Zahl in Lotto.BerechneQuicktipp())
            {
                Text.Append(Zahl.ToString().PadLeft(3));
            }

            Text.AppendLine();

            //Noch einen Hinweis, ob die Zahlen
            //in gezogener oder in aufsteigender Reihenfolge sind
            Text.AppendLine($"(In {(Lotto.Sortiert ? "aufsteigend" : "gezogener")} Reihenfolge)");
            //                                     ^-> Fragezeichen-Doppelpunkt
            //                                        entspricht der WENN-Funktion in Excel
            //                                        eine Binärentscheidung in einer Anweisung
            //                     |--------------------------------------------|
            //                          runde Klammern zur Unterstützung
            //                          der Syntaxprüfung vom Kompiler

            Algorithmus.Ausgeben(Text.ToString());

            //Lotto.dispose... Nicht vorhanden, falls ein
            //                 Objekt ein Dispose() hat,
            //                 IMMER aufrufen, wenn das Objekt
            //                 nicht mehr benötigt wird
            Lotto = null;

            Algorithmus.Ausgeben("ZeigeDurchlaufen beendet.", debug: true);
        }
Ejemplo n.º 2
0
    internal override Zahl f(Zahl x)
    {
        Unexakt z = x.unexakt();

        if (z.imag == 0.0)
        {
            return(new Unexakt(JMath.acos(z.real)));
        }
        return(( Zahl )evalx(trigrule, z));
    }
Ejemplo n.º 3
0
    internal override Zahl f(Zahl x)
    {
        Unexakt z = x.unexakt();

        if (z.real < 0 || z.imag != 0.0)
        {
            return(new Unexakt(JMath.log(z.real * z.real + z.imag * z.imag) / 2, JMath.atan2(z.imag, z.real)));
        }
        return(new Unexakt(JMath.log(z.real)));
    }
Ejemplo n.º 4
0
    public override int lambda(Stack st)
    {
        int  narg    = getNarg(st);
        List cond    = getList(st);
        List step_in = getList(st);
        List thru_in = getList(st);
        List body    = getList(st);

        pc.process_list(cond, true);
        if (pc.stack.Count == 0 || !(pc.stack.Peek() is Zahl) || ((Algebraic)pc.stack.Peek()).Name == null)
        {
            throw new ParseException("Non-constant initializer in for loop.");
        }
        Zahl   x     = (Zahl)pc.stack.Pop();
        string xname = x.Name;

        pc.process_list(step_in, true);
        if (pc.stack.Count == 0 || !(pc.stack.Peek() is Zahl))
        {
            throw new ParseException("Step size must be constant.");
        }
        Zahl step = (Zahl)pc.stack.Pop();

        pc.process_list(thru_in, true);
        if (pc.stack.Count == 0 || !(pc.stack.Peek() is Zahl))
        {
            throw new ParseException("Wrong format in for-loop.");
        }
        Zahl thru = (Zahl)pc.stack.Pop();
        bool pos  = !step.smaller(Zahl.ZERO);

        while (true)
        {
            if ((pos ? thru.smaller(x) : x.smaller(thru)))
            {
                break;
            }
            pc.env.putValue(xname, x);
            int ret = pc.process_list(body, true);
            switch (ret)
            {
            case Processor.BREAK:
                return(0);

            case Processor.RETURN:
            case Processor.EXIT:
            case Processor.ERROR:
                return(ret);

            case Processor.CONTINUE: break;
            }
            x = (Zahl)x.add(step);
        }
        return(0);
    }
Ejemplo n.º 5
0
    private BigInteger[] double2rat(double x)
    {
        BigInteger[] br;

        if (x == 0)
        {
            br = new BigInteger[2];

            br[0] = BigInteger.ZERO;
            br[1] = BigInteger.ONE;

            return(br);
        }

        if (x < 0.0)
        {
            br    = double2rat(-x);
            br[0] = br[0].negate();

            return(br);
        }

        double eps = 1.0e-8;
        Zahl   a   = Lambda.pc.env.getnum("ratepsilon");

        if (a != null)
        {
            double epstry = a.unexakt().real;

            if (epstry > 0)
            {
                eps = epstry;
            }
        }

        if (x < 1 / eps)
        {
            double[] y = cfs(x, eps);

            br = new BigInteger[2];

            br[0] = double2big(y[0]);
            br[1] = double2big(y[1]);

            return(br);
        }

        br = new BigInteger[2];

        br[0] = double2big(x);
        br[1] = BigInteger.ONE;

        return(br);
    }
Ejemplo n.º 6
0
    public virtual Algebraic rat_reverse(Algebraic expr)
    {
        if (gcd.Equals(Zahl.ZERO))
        {
            return(expr);
        }
        Zahl      gc = gcd;
        Algebraic s  = new Exponential(Zahl.ONE, Zahl.ZERO, @var, Zahl.ONE.mult(gc));

        return(expr.value(t, s));
    }
Ejemplo n.º 7
0
    public SubstExp(Variable @var, Algebraic expr)
    {
        this.@var = @var;
        ArrayList v = new ArrayList();

        (new GetExpVars2(v)).f_exakt(expr);
        this.gcd = Exponential.exp_gcd(v, @var);
        if (gcd.Equals(Zahl.ZERO))
        {
            t = @var;
        }
    }
Ejemplo n.º 8
0
    internal override Zahl f(Zahl x)
    {
        Unexakt z = x.unexakt();

        double r = JMath.exp(z.real);

        if (z.imag != 0.0)
        {
            return(new Unexakt(r * Math.Cos(z.imag), r * Math.Sin(z.imag)));
        }

        return(new Unexakt(r));
    }
Ejemplo n.º 9
0
    public override bool smaller(Zahl x)
    {
        Unexakt xu = x.unexakt();

        if (real == xu.real)
        {
            return(imag < xu.imag);
        }
        else
        {
            return(real < xu.real);
        }
    }
Ejemplo n.º 10
0
 static IEnumerable<Zahl> ZahlenreiheQuadrierenEifrig(int maxIndex)
 {
     var result = new Zahl[maxIndex];
     for(int i = 0; i < maxIndex; i++)
     {
         result[i] = new Zahl() {Wert = Quadriere(i)};
     }
     Console.WriteLine("Zahlenreihe erstellt!");
     foreach(var value in result)
     {
         yield return value;
     }
 }
    static IEnumerable <Zahl> ZahlenreiheQuadrierenSofort(int maxIndex)
    {
        var result = new Zahl[maxIndex];

        for (int i = 0; i < maxIndex; i++)
        {
            result[i] = new Zahl()
            {
                Wert = Quadriere(i)
            };
        }
        Console.WriteLine("Zahlenreihe erstellt!");
        return(result);
    }
    static IEnumerable <Zahl> ZahlenreiheQuadrierenEifrig(int maxIndex)
    {
        var result = new Zahl[maxIndex];

        for (int i = 0; i < maxIndex; i++)
        {
            result[i] = new Zahl()
            {
                Wert = Quadriere(i)
            };
        }
        Console.WriteLine("Zahlenreihe erstellt!");
        foreach (var value in result)
        {
            yield return(value);
        }
    }
Ejemplo n.º 13
0
    internal override Zahl f(Zahl x)
    {
        if (!x.integerq() || x.smaller(Zahl.ZERO))
        {
            throw new JasymcaException("Argument to factorial must be a positive integer, is " + x);
        }

        Algebraic r = Zahl.ONE;

        while (Zahl.ONE.smaller(x))
        {
            r = r.mult(x);
            x = ( Zahl )x.sub(Zahl.ONE);
        }

        return(( Zahl )r);
    }
Ejemplo n.º 14
0
    public static Zahl exp_gcd(ArrayList v, Variable x)
    {
        Zahl gcd = Zahl.ZERO;
        int  k   = 0;

        for (int i = 0; i < v.Count; i++)
        {
            Algebraic a = (Algebraic)v[i];
            Algebraic c;
            if (Poly.degree(a, x) == 1 && (c = Poly.coefficient(a, x, 1)) is Zahl)
            {
                k++;
                gcd = gcd.gcd((Zahl)c);
            }
        }
        return(k > 0 ? gcd : Zahl.ONE);
    }
Ejemplo n.º 15
0
    public static Algebraic[] reduce_exp(Algebraic[] p)
    {
        ArrayList   v    = new ArrayList();
        ArrayList   vars = new ArrayList();
        GetExpVars2 g    = new GetExpVars2(v);

        for (int i = 0; i < p.Length; i++)
        {
            g.f_exakt(p[i]);
        }
        for (int i = 0; i < v.Count; i++)
        {
            Algebraic a = (Algebraic)v[i];
            Variable  x = null;
            if (a is Polynomial)
            {
                x = ((Polynomial)a).v;
            }
            else
            {
                continue;
            }
            if (vars.Contains(x))
            {
                continue;
            }
            else
            {
                vars.Add(x);
            }
            Zahl gcd = exp_gcd(v, x);
            if (!gcd.Equals(Zahl.ZERO) && !gcd.Equals(Zahl.ONE))
            {
                SubstExp sb = new SubstExp(gcd, x);
                for (int k = 0; k < p.Length; k++)
                {
                    p[k] = sb.f_exakt(p[k]);
                }
            }
        }
        return(p);
    }
Ejemplo n.º 16
0
        private void button2_Click(object sender, EventArgs e)
        {
            String Zahl;

            Zahl = Convert.ToString(textBox1.Text);

            string delimStr = " ";

            char[]   delimiter = delimStr.ToCharArray();
            string[] split     = null;
            for (int x = 1; x <= 5; x++)
            {
                split = Zahl.Split(delimiter, x);
            }

            int[] Zahl1 = new int [split.Length];

            for (int i = 0; i < split.Length; i++)
            {
                Zahl1[i] = Convert.ToInt32(split[i]);
            }


            String[] Buch = new string[26] {
                "B", "A", "U", "M", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "N", "O", "P", "Q", "R", "S", "T", "V", "W", "X", "Y", "Z"
            };

            string[] code = new string[Zahl1.Length];

            for (int i = 0; i < Zahl1.Length; i++)
            {
                code[i] = Buch[Zahl1[i]];
            }



            String schluessel = string.Join(" ", code);

            textBox2.Text = Convert.ToString(schluessel);
        }
Ejemplo n.º 17
0
 static IEnumerable<Zahl> ZahlenreiheQuadrierenSofort(int maxIndex)
 {
     var result = new Zahl[maxIndex];
     for(int i = 0; i < maxIndex; i++)
     {
         result[i] = new Zahl() {Wert = Quadriere(i)};
     }
     Console.WriteLine("Zahlenreihe erstellt!");
     return result;
 }
Ejemplo n.º 18
0
 public override bool smaller(Zahl x)
 {
     return(unexakt().smaller(x));
 }
Ejemplo n.º 19
0
 internal override Zahl f(Zahl x)
 {
     return(new Unexakt(Sfun.logGamma(x.unexakt().real)));
 }
Ejemplo n.º 20
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public int lambda(Stack st) throws ParseException, JasymcaException
    public override int lambda(Stack st)
    {
        int narg = getNarg(st);

        if (narg != 4)
        {
            throw new ParseException("Usage: ROMBERG (exp,var,ll,ul)");
        }
        Algebraic       exp = getAlgebraic(st);
        Variable        v   = getVariable(st);
        Algebraic       ll  = getAlgebraic(st);
        Algebraic       ul  = getAlgebraic(st);
        LambdaAlgebraic xc  = new ExpandConstants();

        exp = xc.f_exakt(exp);
        ll  = xc.f_exakt(ll);
        ul  = xc.f_exakt(ul);
        if (!(ll is Zahl) || !(ul is Zahl))
        {
            throw new ParseException("Usage: ROMBERG (exp,var,ll,ul)");
        }
        double rombergtol = 1.0e-4;
        int    rombergit  = 11;
        Zahl   a1         = pc.env.getnum("rombergit");

        if (a1 != null)
        {
            rombergit = a1.intval();
        }
        a1 = pc.env.getnum("rombergtol");
        if (a1 != null)
        {
            rombergtol = a1.unexakt().real;
        }
        double a = ((Zahl)ll).unexakt().real;
        double b = ((Zahl)ul).unexakt().real;

//JAVA TO C# CONVERTER NOTE: The following call to the 'RectangularArrays' helper class reproduces the rectangular array initialization that is automatic in Java:
//ORIGINAL LINE: double[][] I = new double[rombergit][rombergit];
        double[][] I = RectangularArrays.ReturnRectangularDoubleArray(rombergit, rombergit);
        int        i = 0, n = 1;
        Algebraic  t = trapez(exp, v, n, a, b);

        if (!(t is Zahl))
        {
            throw new ParseException("Expression must evaluate to number");
        }
        I[0][0] = ((Zahl)t).unexakt().real;
        double epsa = 1.1 * rombergtol;

        while (epsa > rombergtol && i < rombergit - 1)
        {
            i++;
            n      *= 2;
            t       = trapez(exp, v, n, a, b);
            I[0][i] = ((Zahl)t).unexakt().real;
            double f = 1.0;
            for (int k = 1; k <= i; k++)
            {
                f      *= 4;
                I[k][i] = I[k - 1][i] + (I[k - 1][i] - I[k - 1][i - 1]) / (f - 1.0);
            }
            epsa = Math.Abs((I[i][i] - I[i - 1][i - 1]) / I[i][i]);
        }
        st.Push(new Unexakt(I[i][i]));
        return(0);
    }
Ejemplo n.º 21
0
 internal override Zahl f(Zahl x)
 {
     return(( Zahl )f_exakt(x));
 }
Ejemplo n.º 22
0
 internal override Zahl f(Zahl x)
 {
     return(x.Equals(Zahl.ZERO) ? Zahl.ONE : Zahl.ZERO);
 }
Ejemplo n.º 23
0
 public SubstExp(Zahl gcd, Variable @var)
 {
     this.gcd  = gcd;
     this.@var = @var;
 }
Ejemplo n.º 24
0
 public abstract bool smaller(Zahl x);
Ejemplo n.º 25
0
 public virtual Zahl gcd(Zahl x)
 {
     return(exakt().gcd(x.exakt()));
 }
Ejemplo n.º 26
0
    internal virtual Algebraic fzexakt(Zahl x)
    {
        if (x.smaller(Zahl.ZERO))
        {
            Algebraic r = fzexakt((Zahl)x.mult(Zahl.MINUS));
            if (r != null)
            {
                return(r.cc());
            }
            return(r);
        }

        if (x.integerq())
        {
            if (x.intval() % 2 == 0)
            {
                return(Zahl.ONE);
            }
            else
            {
                return(Zahl.MINUS);
            }
        }

        Algebraic qs = x.add(new Unexakt(.5));

        if (((Zahl)qs).integerq())
        {
            if (((Zahl)qs).intval() % 2 == 0)
            {
                return(Zahl.IMINUS);
            }
            else
            {
                return(Zahl.IONE);
            }
        }

        qs = x.mult(new Unexakt(4));

        if (((Zahl)qs).integerq())
        {
            Algebraic sq2 = FunctionVariable.create("sqrt", new Unexakt(0.5));
            switch (((Zahl)qs).intval() % 8)
            {
            case 1:
                return(Zahl.ONE.add(Zahl.IONE).div(Zahl.SQRT2));

            case 3:
                return(Zahl.MINUS.add(Zahl.IONE).div(Zahl.SQRT2));

            case 5:
                return(Zahl.MINUS.add(Zahl.IMINUS).div(Zahl.SQRT2));

            case 7:
                return(Zahl.ONE.add(Zahl.IMINUS).div(Zahl.SQRT2));
            }
        }
        qs = x.mult(new Unexakt(6));
        if (((Zahl)qs).integerq())
        {
            switch (((Zahl)qs).intval() % 12)
            {
            case 1:
                return(Zahl.SQRT3.add(Zahl.IONE).div(Zahl.TWO));

            case 2:
                return(Zahl.ONE.add(Zahl.SQRT3.mult(Zahl.IONE)).div(Zahl.TWO));

            case 4:
                return(Zahl.SQRT3.mult(Zahl.IONE).add(Zahl.MINUS).div(Zahl.TWO));

            case 5:
                return(Zahl.IONE.sub(Zahl.SQRT3).div(Zahl.TWO));

            case 7:
                return(Zahl.IMINUS.sub(Zahl.SQRT3).div(Zahl.TWO));

            case 8:
                return(Zahl.SQRT3.mult(Zahl.IMINUS).sub(Zahl.ONE).div(Zahl.TWO));

            case 10:
                return(Zahl.SQRT3.mult(Zahl.IMINUS).add(Zahl.ONE).div(Zahl.TWO));

            case 11:
                return(Zahl.IMINUS.add(Zahl.SQRT3).div(Zahl.TWO));
            }
        }
        return(null);
    }
Ejemplo n.º 27
0
 internal override Zahl f(Zahl x)
 {
     return(null);
 }