Exemple #1
0
        public void CloneTest()
        {
            var exp   = new Arccsc(new Number(1));
            var clone = exp.Clone();

            Assert.Equal(exp, clone);
        }
Exemple #2
0
        public void ArccscCsc()
        {
            var exp      = new Arccsc(new Csc(Variable.X));
            var expected = Variable.X;

            SimpleTest(exp, expected);
        }
Exemple #3
0
        public void ArccscCsc()
        {
            var exp      = new Arccsc(new Csc(new Variable("x")));
            var expected = new Variable("x");

            SimpleTest(exp, expected);
        }
Exemple #4
0
        public void ExecuteComplexNumberTest()
        {
            var complex = new Complex(3, 2);
            var exp     = new Arccsc(new ComplexNumber(complex));
            var result  = (Complex)exp.Execute();

            Assert.Equal(ComplexExtensions.Acsc(complex), result);
            Assert.Equal(0.22996290237720782, result.Real, 15);
            Assert.Equal(-0.15735549884498545, result.Imaginary, 15);
        }
Exemple #5
0
        /// <summary>
        /// Analyzes the specified expression.
        /// </summary>
        /// <param name="exp">The expression.</param>
        /// <returns>
        /// The result of analysis.
        /// </returns>
        public override IExpression Analyze(Arccsc exp)
        {
            if (!Helpers.HasVariable(exp, Variable))
            {
                return(new Number(0));
            }

            var abs   = new Abs(exp.Argument.Clone());
            var sqr   = new Pow(exp.Argument.Clone(), new Number(2));
            var sub   = new Sub(sqr, new Number(1));
            var sqrt  = new Sqrt(sub);
            var mul   = new Mul(abs, sqrt);
            var div   = new Div(exp.Argument.Clone().Analyze(this), mul);
            var unary = new UnaryMinus(div);

            return(unary);
        }
Exemple #6
0
 /// <summary>
 /// Analyzes the specified expression.
 /// </summary>
 /// <param name="exp">The expression.</param>
 /// <returns>
 /// The result of analysis.
 /// </returns>
 /// <exception cref="System.NotSupportedException">Always.</exception>
 public virtual TResult Analyze(Arccsc exp)
 {
     throw new NotSupportedException();
 }
Exemple #7
0
 /// <summary>
 /// Analyzes the specified expression.
 /// </summary>
 /// <param name="exp">The expression.</param>
 /// <returns>The result of analysis.</returns>
 public string Analyze(Arccsc exp)
 {
     return(ToString(exp, "arccsc({0})"));
 }
Exemple #8
0
        /// <summary>
        /// Creates an expression object from <see cref="FunctionToken"/>.
        /// </summary>
        /// <param name="token">The function token.</param>
        /// <returns>An expression.</returns>
        protected virtual IExpression CreateFunction(FunctionToken token)
        {
            IExpression exp;

            switch (token.Function)
            {
            case Functions.Add:
                exp = new Add(); break;

            case Functions.Sub:
                exp = new Sub(); break;

            case Functions.Mul:
                exp = new Mul(); break;

            case Functions.Div:
                exp = new Div(); break;

            case Functions.Pow:
                exp = new Pow(); break;

            case Functions.Absolute:
                exp = new Abs(); break;

            case Functions.Sine:
                exp = new Sin(); break;

            case Functions.Cosine:
                exp = new Cos(); break;

            case Functions.Tangent:
                exp = new Tan(); break;

            case Functions.Cotangent:
                exp = new Cot(); break;

            case Functions.Secant:
                exp = new Sec(); break;

            case Functions.Cosecant:
                exp = new Csc(); break;

            case Functions.Arcsine:
                exp = new Arcsin(); break;

            case Functions.Arccosine:
                exp = new Arccos(); break;

            case Functions.Arctangent:
                exp = new Arctan(); break;

            case Functions.Arccotangent:
                exp = new Arccot(); break;

            case Functions.Arcsecant:
                exp = new Arcsec(); break;

            case Functions.Arccosecant:
                exp = new Arccsc(); break;

            case Functions.Sqrt:
                exp = new Sqrt(); break;

            case Functions.Root:
                exp = new Root(); break;

            case Functions.Ln:
                exp = new Ln(); break;

            case Functions.Lg:
                exp = new Lg(); break;

            case Functions.Lb:
                exp = new Lb(); break;

            case Functions.Log:
                exp = new Log(); break;

            case Functions.Sineh:
                exp = new Sinh(); break;

            case Functions.Cosineh:
                exp = new Cosh(); break;

            case Functions.Tangenth:
                exp = new Tanh(); break;

            case Functions.Cotangenth:
                exp = new Coth(); break;

            case Functions.Secanth:
                exp = new Sech(); break;

            case Functions.Cosecanth:
                exp = new Csch(); break;

            case Functions.Arsineh:
                exp = new Arsinh(); break;

            case Functions.Arcosineh:
                exp = new Arcosh(); break;

            case Functions.Artangenth:
                exp = new Artanh(); break;

            case Functions.Arcotangenth:
                exp = new Arcoth(); break;

            case Functions.Arsecanth:
                exp = new Arsech(); break;

            case Functions.Arcosecanth:
                exp = new Arcsch(); break;

            case Functions.Exp:
                exp = new Exp(); break;

            case Functions.GCD:
                exp = new GCD(); break;

            case Functions.LCM:
                exp = new LCM(); break;

            case Functions.Factorial:
                exp = new Fact(); break;

            case Functions.Sum:
                exp = new Sum(); break;

            case Functions.Product:
                exp = new Product(); break;

            case Functions.Round:
                exp = new Round(); break;

            case Functions.Floor:
                exp = new Floor(); break;

            case Functions.Ceil:
                exp = new Ceil(); break;

            case Functions.Derivative:
                exp = new Derivative(); break;

            case Functions.Simplify:
                exp = new Simplify(); break;

            case Functions.Del:
                exp = new Del(); break;

            case Functions.Define:
                exp = new Define(); break;

            case Functions.Vector:
                exp = new Vector(); break;

            case Functions.Matrix:
                exp = new Matrix(); break;

            case Functions.Transpose:
                exp = new Transpose(); break;

            case Functions.Determinant:
                exp = new Determinant(); break;

            case Functions.Inverse:
                exp = new Inverse(); break;

            case Functions.If:
                exp = new If(); break;

            case Functions.For:
                exp = new For(); break;

            case Functions.While:
                exp = new While(); break;

            case Functions.Undefine:
                exp = new Undefine(); break;

            case Functions.Im:
                exp = new Im(); break;

            case Functions.Re:
                exp = new Re(); break;

            case Functions.Phase:
                exp = new Phase(); break;

            case Functions.Conjugate:
                exp = new Conjugate(); break;

            case Functions.Reciprocal:
                exp = new Reciprocal(); break;

            case Functions.Min:
                exp = new Min(); break;

            case Functions.Max:
                exp = new Max(); break;

            case Functions.Avg:
                exp = new Avg(); break;

            case Functions.Count:
                exp = new Count(); break;

            case Functions.Var:
                exp = new Var(); break;

            case Functions.Varp:
                exp = new Varp(); break;

            case Functions.Stdev:
                exp = new Stdev(); break;

            case Functions.Stdevp:
                exp = new Stdevp(); break;

            default:
                exp = null; break;
            }

            if (exp is DifferentParametersExpression diff)
            {
                diff.ParametersCount = token.CountOfParams;
            }

            return(exp);
        }
        public void ArccscToStringTest()
        {
            var exp = new Arccsc(new Number(5));

            Assert.Equal("arccsc(5)", exp.ToString(commoonFormatter));
        }
Exemple #10
0
        public void ExecuteTestException()
        {
            var exp = new Arccsc(new Bool(false));

            Assert.Throws <ResultIsNotSupportedException>(() => exp.Execute());
        }
Exemple #11
0
        public void ExecuteGradianTest()
        {
            var exp = new Arccsc(new Number(1));

            Assert.Equal(MathExtensions.Acsc(1) / Math.PI * 200, exp.Execute(AngleMeasurement.Gradian));
        }
Exemple #12
0
        public void ExecuteDegreeTest()
        {
            var exp = new Arccsc(new Number(1));

            Assert.Equal(MathExtensions.Acsc(1) / Math.PI * 180, exp.Execute(AngleMeasurement.Degree));
        }
Exemple #13
0
        public void TestArccscNumber()
        {
            var exp = new Arccsc(new Number(2));

            Test(exp, ResultType.Number);
        }
Exemple #14
0
        public void TestArccscUndefined()
        {
            var exp = new Arccsc(Variable.X);

            Test(exp, ResultType.Undefined);
        }
Exemple #15
0
        public void TestArccscException()
        {
            var exp = new Arccsc(new Bool(false));

            TestException(exp);
        }
Exemple #16
0
        public void TestArccscComplexNumber()
        {
            var exp = new Arccsc(new ComplexNumber(2, 2));

            Test(exp, ResultType.ComplexNumber);
        }