Exemplo n.º 1
0
        public void TestWithUndefined3()
        {
            var a = RealNumber.NegativeInfinity();
            var b = RealNumber.NegativeInfinity();

            Assert.IsTrue(a * b == RealNumber.PositiveInfinity());
        }
Exemplo n.º 2
0
        public void TestWithUndefined5()
        {
            var a = new RealNumber(4);
            var b = new RealNumber(0.0m);

            Assert.IsTrue(a / b == RealNumber.PositiveInfinity());
        }
Exemplo n.º 3
0
 /// <summary>
 /// Returns a set of all real numbers
 /// </summary>
 /// <returns></returns>
 internal static Set R()
 => new Set
 {
     Pieces = new List <Piece>
     {
         Piece.Interval(
             Number.Create(RealNumber.NegativeInfinity(), 0),
             Number.Create(RealNumber.PositiveInfinity(), 0)
             ).AsInterval().SetLeftClosed(false).SetRightClosed(false)
     }
 };
Exemplo n.º 4
0
 [TestMethod] public void MOOMOOI() => Test(@"-\infty  - \infty i", RealNumber.PositiveInfinity() * (-1 - MathS.i));
Exemplo n.º 5
0
 [TestMethod] public void OOPOOI() => Test(@"\infty  + \infty i", RealNumber.PositiveInfinity() * (1 + MathS.i));
Exemplo n.º 6
0
 [TestMethod] public void OOMI() => Test(@"\infty  - i", RealNumber.PositiveInfinity() - MathS.i);
Exemplo n.º 7
0
 [TestMethod] public void MOOAlternate() => Test(@"-\infty ", -RealNumber.PositiveInfinity());
Exemplo n.º 8
0
 [TestMethod] public void OO() => Test(@"\infty ", RealNumber.PositiveInfinity());
Exemplo n.º 9
0
 [TestMethod] public void Undefined() => TestSimplify(@"\mathrm{undefined}", RealNumber.PositiveInfinity() / RealNumber.PositiveInfinity());
Exemplo n.º 10
0
        /// <summary>
        /// Calls the compiled function (synonim to Call)
        /// </summary>
        /// <param name="variables">
        /// List arguments in the same order in which you compiled the function
        /// </param>
        /// <returns></returns>
        public ComplexNumber Substitute(params ComplexNumber[] variables)
        {
            if (variables.Length != varCount)
            {
                throw new SysException("Wrong amount of parameters");
            }
            Instruction instruction;

            for (int i = 0; i < instructions.Count; i++)
            {
                instruction = instructions[i];
                switch (instruction.Type)
                {
                case Instruction.InstructionType.PUSHVAR:
                    stack.Push(variables[instruction.VarNumber].AsComplex());
                    break;

                case Instruction.InstructionType.PUSHCONST:
                    stack.Push(instruction.Value);
                    break;

                case Instruction.InstructionType.CALL:
                    switch (instruction.FuncNumber)
                    {
                    case 0:
                        stack.Push(stack.Pop() + stack.Pop());
                        break;

                    case 1:
                        stack.Push(stack.Pop() - stack.Pop());
                        break;

                    case 2:
                        stack.Push(stack.Pop() * stack.Pop());
                        break;

                    case 3:
                        stack.Push(stack.Pop() / stack.Pop());
                        break;

                    case 4:
                        stack.Push(Complex.Pow(stack.Pop(), stack.Pop()));
                        break;

                    case 5:
                        stack.Push(Complex.Sin(stack.Pop()));
                        break;

                    case 6:
                        stack.Push(Complex.Cos(stack.Pop()));
                        break;

                    case 7:
                        stack.Push(Complex.Tan(stack.Pop()));
                        break;

                    case 8:
                        stack.Push(1 / Complex.Tan(stack.Pop()));
                        break;

                    case 9:
                        stack.Push(Complex.Log(stack.Pop(), stack.Pop().Real));
                        break;

                    case 10:
                        stack.Push(Complex.Asin(stack.Pop()));
                        break;

                    case 11:
                        stack.Push(Complex.Acos(stack.Pop()));
                        break;

                    case 12:
                        stack.Push(Complex.Atan(stack.Pop()));
                        break;

                    case 13:
                        stack.Push(Complex.Atan(1 / stack.Pop()));
                        break;
                    }
                    break;

                case Instruction.InstructionType.PULLCACHE:
                    stack.Push(Cache[instruction.CacheNumber]);
                    break;

                default:
                    Cache[instruction.CacheNumber] = stack.Peek();
                    break;
                }
            }
            var res = stack.Pop();

            RealNumber Normalize(double value)
            {
                if (value > maxDecimal)
                {
                    return(RealNumber.PositiveInfinity());
                }
                else if (value < minDecimal)
                {
                    return(RealNumber.NegativeInfinity());
                }
                else
                {
                    return(Number.Create(value));
                }
            }

            var re = Normalize(res.Real);
            var im = Normalize(res.Imaginary);

            return(Number.Create(re, im));
        }
Exemplo n.º 11
0
 public void TestWithUndefined13()
 {
     Assert.IsTrue(RealNumber.PositiveInfinity() / RealNumber.NegativeInfinity() == RealNumber.NaN());
 }
Exemplo n.º 12
0
 public void TestWithUndefined11()
 {
     Assert.IsTrue(RealNumber.PositiveInfinity() / 5 == RealNumber.PositiveInfinity());
 }
Exemplo n.º 13
0
        public void TestWithUndefined10()
        {
            var x = new RealNumber(0.5);

            Assert.IsTrue(x / RealNumber.PositiveInfinity() == 0);
        }
Exemplo n.º 14
0
        public void TestWithUndefined9()
        {
            var x = new RationalNumber(Number.Create(-1), Number.Create(2));

            Assert.IsTrue(x / RealNumber.PositiveInfinity() == 0);
        }