public void TestWithUndefined4() { var a = RealNumber.NegativeInfinity(); var b = RealNumber.NaN(); Assert.IsTrue(a * b == RealNumber.NaN()); }
/// <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) } };
[TestMethod] public void MOO() => Test(@"-\infty ", RealNumber.NegativeInfinity());
public void TestWithUndefined8() { var x = new RationalNumber(Number.Create(-1), Number.Create(2)); Assert.IsTrue(x / 0 == RealNumber.NegativeInfinity()); }
/// <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)); }
public void TestWithUndefined14() { Assert.IsTrue(RealNumber.NegativeInfinity() / 5 == RealNumber.NegativeInfinity()); }
public void TestWithUndefined13() { Assert.IsTrue(RealNumber.PositiveInfinity() / RealNumber.NegativeInfinity() == RealNumber.NaN()); }