Exemplo n.º 1
0
        /// <summary>
        /// Analyzes the specified expression.
        /// </summary>
        /// <param name="exp">The expression.</param>
        /// <returns>
        /// The result of analysis.
        /// </returns>
        public override IExpression Analyze(Log exp)
        {
            if (!Helpers.HasVariable(exp, Variable))
            {
                return(new Number(0));
            }

            if (Helpers.HasVariable(exp.Left, Variable))
            {
                var ln1 = new Ln(exp.Right.Clone());
                var ln2 = new Ln(exp.Left.Clone());
                var div = new Div(ln1, ln2);

                return(Analyze(div));
            }

            // if (Helpers.HasVar(exp.Right, variable))
            var ln   = new Ln(exp.Left.Clone());
            var mul  = new Mul(exp.Right.Clone(), ln);
            var div2 = new Div(exp.Right.Clone().Analyze(this), mul);

            return(div2);
        }
Exemplo n.º 2
0
        public void LnFunctionWithErrorValuesAsInputReturnsTheInputErrorValue()
        {
            var func        = new Ln();
            var argNA       = FunctionsHelper.CreateArgs(ExcelErrorValue.Create(eErrorType.NA));
            var argNAME     = FunctionsHelper.CreateArgs(ExcelErrorValue.Create(eErrorType.Name));
            var argVALUE    = FunctionsHelper.CreateArgs(ExcelErrorValue.Create(eErrorType.Value));
            var argNUM      = FunctionsHelper.CreateArgs(ExcelErrorValue.Create(eErrorType.Num));
            var argDIV0     = FunctionsHelper.CreateArgs(ExcelErrorValue.Create(eErrorType.Div0));
            var argREF      = FunctionsHelper.CreateArgs(ExcelErrorValue.Create(eErrorType.Ref));
            var resultNA    = func.Execute(argNA, this.ParsingContext);
            var resultNAME  = func.Execute(argNAME, this.ParsingContext);
            var resultVALUE = func.Execute(argVALUE, this.ParsingContext);
            var resultNUM   = func.Execute(argNUM, this.ParsingContext);
            var resultDIV0  = func.Execute(argDIV0, this.ParsingContext);
            var resultREF   = func.Execute(argREF, this.ParsingContext);

            Assert.AreEqual(eErrorType.NA, ((ExcelErrorValue)resultNA.Result).Type);
            Assert.AreEqual(eErrorType.Name, ((ExcelErrorValue)resultNAME.Result).Type);
            Assert.AreEqual(eErrorType.Value, ((ExcelErrorValue)resultVALUE.Result).Type);
            Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)resultNUM.Result).Type);
            Assert.AreEqual(eErrorType.Div0, ((ExcelErrorValue)resultDIV0.Result).Type);
            Assert.AreEqual(eErrorType.Ref, ((ExcelErrorValue)resultREF.Result).Type);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Analyzes the specified expression.
        /// </summary>
        /// <param name="exp">The expression.</param>
        /// <returns>
        /// The result of analysis.
        /// </returns>
        public override IExpression Analyze(Pow exp)
        {
            if (!Helpers.HasVariable(exp, Variable))
            {
                return(new Number(0));
            }

            if (Helpers.HasVariable(exp.Left, Variable))
            {
                var sub  = new Sub(exp.Right.Clone(), new Number(1));
                var inv  = new Pow(exp.Left.Clone(), sub);
                var mul1 = new Mul(exp.Right.Clone(), inv);
                var mul2 = new Mul(exp.Left.Clone().Analyze(this), mul1);

                return(mul2);
            }

            // if (Helpers.HasVar(exp.Right, variable))
            var ln   = new Ln(exp.Left.Clone());
            var mul3 = new Mul(ln, exp.Clone());
            var mul4 = new Mul(mul3, exp.Right.Clone().Analyze(this));

            return(mul4);
        }
 public void lnRaster(object inRaster, string outRst)
 {
     Ln ln = new Ln();
     ln.in_raster_or_constant = inRaster;
     ln.out_raster = outRst;
     string rsl = getMessages(gpExecute(ln));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Analyzes the specified expression.
 /// </summary>
 /// <param name="exp">The expression.</param>
 /// <returns>The result of analysis.</returns>
 public string Analyze(Ln exp)
 {
     return(ToString(exp, "ln({0})"));
 }
Exemplo n.º 6
0
 public BuiltInFunctions()
 {
     // Text
     Functions["len"]         = new Len();
     Functions["lower"]       = new Lower();
     Functions["upper"]       = new Upper();
     Functions["left"]        = new Left();
     Functions["right"]       = new Right();
     Functions["mid"]         = new Mid();
     Functions["replace"]     = new Replace();
     Functions["rept"]        = new Rept();
     Functions["substitute"]  = new Substitute();
     Functions["concatenate"] = new Concatenate();
     Functions["char"]        = new CharFunction();
     Functions["exact"]       = new Exact();
     Functions["find"]        = new Find();
     Functions["fixed"]       = new Fixed();
     Functions["proper"]      = new Proper();
     Functions["search"]      = new Search();
     Functions["text"]        = new Text.Text();
     Functions["t"]           = new T();
     Functions["hyperlink"]   = new Hyperlink();
     Functions["value"]       = new Value();
     // Numbers
     Functions["int"] = new CInt();
     // Math
     Functions["abs"]         = new Abs();
     Functions["asin"]        = new Asin();
     Functions["asinh"]       = new Asinh();
     Functions["cos"]         = new Cos();
     Functions["cosh"]        = new Cosh();
     Functions["power"]       = new Power();
     Functions["sign"]        = new Sign();
     Functions["sqrt"]        = new Sqrt();
     Functions["sqrtpi"]      = new SqrtPi();
     Functions["pi"]          = new Pi();
     Functions["product"]     = new Product();
     Functions["ceiling"]     = new Ceiling();
     Functions["count"]       = new Count();
     Functions["counta"]      = new CountA();
     Functions["countblank"]  = new CountBlank();
     Functions["countif"]     = new CountIf();
     Functions["countifs"]    = new CountIfs();
     Functions["fact"]        = new Fact();
     Functions["floor"]       = new Floor();
     Functions["sin"]         = new Sin();
     Functions["sinh"]        = new Sinh();
     Functions["sum"]         = new Sum();
     Functions["sumif"]       = new SumIf();
     Functions["sumifs"]      = new SumIfs();
     Functions["sumproduct"]  = new SumProduct();
     Functions["sumsq"]       = new Sumsq();
     Functions["stdev"]       = new Stdev();
     Functions["stdevp"]      = new StdevP();
     Functions["stdev.s"]     = new Stdev();
     Functions["stdev.p"]     = new StdevP();
     Functions["subtotal"]    = new Subtotal();
     Functions["exp"]         = new Exp();
     Functions["log"]         = new Log();
     Functions["log10"]       = new Log10();
     Functions["ln"]          = new Ln();
     Functions["max"]         = new Max();
     Functions["maxa"]        = new Maxa();
     Functions["median"]      = new Median();
     Functions["min"]         = new Min();
     Functions["mina"]        = new Mina();
     Functions["mod"]         = new Mod();
     Functions["average"]     = new Average();
     Functions["averagea"]    = new AverageA();
     Functions["averageif"]   = new AverageIf();
     Functions["averageifs"]  = new AverageIfs();
     Functions["round"]       = new Round();
     Functions["rounddown"]   = new Rounddown();
     Functions["roundup"]     = new Roundup();
     Functions["rand"]        = new Rand();
     Functions["randbetween"] = new RandBetween();
     Functions["rank"]        = new Rank();
     Functions["rank.eq"]     = new Rank();
     Functions["rank.avg"]    = new Rank(true);
     Functions["quotient"]    = new Quotient();
     Functions["trunc"]       = new Trunc();
     Functions["tan"]         = new Tan();
     Functions["tanh"]        = new Tanh();
     Functions["atan"]        = new Atan();
     Functions["atan2"]       = new Atan2();
     Functions["atanh"]       = new Atanh();
     Functions["acos"]        = new Acos();
     Functions["acosh"]       = new Acosh();
     Functions["var"]         = new Var();
     Functions["varp"]        = new VarP();
     Functions["large"]       = new Large();
     Functions["small"]       = new Small();
     Functions["degrees"]     = new Degrees();
     // Information
     Functions["isblank"]    = new IsBlank();
     Functions["isnumber"]   = new IsNumber();
     Functions["istext"]     = new IsText();
     Functions["isnontext"]  = new IsNonText();
     Functions["iserror"]    = new IsError();
     Functions["iserr"]      = new IsErr();
     Functions["error.type"] = new ErrorType();
     Functions["iseven"]     = new IsEven();
     Functions["isodd"]      = new IsOdd();
     Functions["islogical"]  = new IsLogical();
     Functions["isna"]       = new IsNa();
     Functions["na"]         = new Na();
     Functions["n"]          = new N();
     // Logical
     Functions["if"]      = new If();
     Functions["iferror"] = new IfError();
     Functions["ifna"]    = new IfNa();
     Functions["not"]     = new Not();
     Functions["and"]     = new And();
     Functions["or"]      = new Or();
     Functions["true"]    = new True();
     Functions["false"]   = new False();
     // Reference and lookup
     Functions["address"]  = new Address();
     Functions["hlookup"]  = new HLookup();
     Functions["vlookup"]  = new VLookup();
     Functions["lookup"]   = new Lookup();
     Functions["match"]    = new Match();
     Functions["row"]      = new Row();
     Functions["rows"]     = new Rows();
     Functions["column"]   = new Column();
     Functions["columns"]  = new Columns();
     Functions["choose"]   = new Choose();
     Functions["index"]    = new RefAndLookup.Index();
     Functions["indirect"] = new Indirect();
     Functions["offset"]   = new Offset();
     // Date
     Functions["date"]             = new Date();
     Functions["today"]            = new Today();
     Functions["now"]              = new Now();
     Functions["day"]              = new Day();
     Functions["month"]            = new Month();
     Functions["year"]             = new Year();
     Functions["time"]             = new Time();
     Functions["hour"]             = new Hour();
     Functions["minute"]           = new Minute();
     Functions["second"]           = new Second();
     Functions["weeknum"]          = new Weeknum();
     Functions["weekday"]          = new Weekday();
     Functions["days360"]          = new Days360();
     Functions["yearfrac"]         = new Yearfrac();
     Functions["edate"]            = new Edate();
     Functions["eomonth"]          = new Eomonth();
     Functions["isoweeknum"]       = new IsoWeekNum();
     Functions["workday"]          = new Workday();
     Functions["networkdays"]      = new Networkdays();
     Functions["networkdays.intl"] = new NetworkdaysIntl();
     Functions["datevalue"]        = new DateValue();
     Functions["timevalue"]        = new TimeValue();
     // Database
     Functions["dget"]     = new Dget();
     Functions["dcount"]   = new Dcount();
     Functions["dcounta"]  = new DcountA();
     Functions["dmax"]     = new Dmax();
     Functions["dmin"]     = new Dmin();
     Functions["dsum"]     = new Dsum();
     Functions["daverage"] = new Daverage();
     Functions["dvar"]     = new Dvar();
     Functions["dvarp"]    = new Dvarp();
     //Finance
     Functions["pmt"] = new Pmt();
 }
Exemplo n.º 7
0
 public BuiltInFunctions()
 {
     // Text
     Functions["len"]         = new Len();
     Functions["lower"]       = new Lower();
     Functions["upper"]       = new Upper();
     Functions["left"]        = new Left();
     Functions["right"]       = new Right();
     Functions["mid"]         = new Mid();
     Functions["replace"]     = new Replace();
     Functions["rept"]        = new Rept();
     Functions["substitute"]  = new Substitute();
     Functions["concatenate"] = new Concatenate();
     Functions["concat"]      = new Concat();
     Functions["textjoin"]    = new Textjoin();
     Functions["char"]        = new CharFunction();
     Functions["exact"]       = new Exact();
     Functions["find"]        = new Find();
     Functions["fixed"]       = new Fixed();
     Functions["proper"]      = new Proper();
     Functions["search"]      = new Search();
     Functions["text"]        = new Text.Text();
     Functions["t"]           = new T();
     Functions["hyperlink"]   = new Hyperlink();
     Functions["value"]       = new Value(CultureInfo.CurrentCulture);
     Functions["trim"]        = new Trim();
     Functions["clean"]       = new Clean();
     Functions["unicode"]     = new Unicode();
     Functions["unichar"]     = new Unichar();
     Functions["numbervalue"] = new NumberValue();
     Functions["dollar"]      = new Dollar();
     // Numbers
     Functions["int"] = new CInt();
     // Math
     Functions["aggregate"]       = new Aggregate();
     Functions["abs"]             = new Abs();
     Functions["asin"]            = new Asin();
     Functions["asinh"]           = new Asinh();
     Functions["acot"]            = new Acot();
     Functions["acoth"]           = new Acoth();
     Functions["cos"]             = new Cos();
     Functions["cot"]             = new Cot();
     Functions["coth"]            = new Coth();
     Functions["cosh"]            = new Cosh();
     Functions["csc"]             = new Csc();
     Functions["csch"]            = new Csch();
     Functions["power"]           = new Power();
     Functions["gcd"]             = new Gcd();
     Functions["lcm"]             = new Lcm();
     Functions["sec"]             = new Sec();
     Functions["sech"]            = new SecH();
     Functions["sign"]            = new Sign();
     Functions["sqrt"]            = new Sqrt();
     Functions["sqrtpi"]          = new SqrtPi();
     Functions["pi"]              = new Pi();
     Functions["product"]         = new Product();
     Functions["ceiling"]         = new Ceiling();
     Functions["ceiling.precise"] = new CeilingPrecise();
     Functions["ceiling.math"]    = new CeilingMath();
     Functions["iso.ceiling"]     = new IsoCeiling();
     Functions["combin"]          = new Combin();
     Functions["combina"]         = new Combina();
     Functions["permut"]          = new Permut();
     Functions["permutationa"]    = new Permutationa();
     Functions["count"]           = new Count();
     Functions["counta"]          = new CountA();
     Functions["countblank"]      = new CountBlank();
     Functions["countif"]         = new CountIf();
     Functions["countifs"]        = new CountIfs();
     Functions["fact"]            = new Fact();
     Functions["factdouble"]      = new FactDouble();
     Functions["floor"]           = new Floor();
     Functions["floor.precise"]   = new FloorPrecise();
     Functions["floor.math"]      = new FloorMath();
     Functions["radians"]         = new Radians();
     Functions["roman"]           = new Roman();
     Functions["sin"]             = new Sin();
     Functions["sinh"]            = new Sinh();
     Functions["sum"]             = new Sum();
     Functions["sumif"]           = new SumIf();
     Functions["sumifs"]          = new SumIfs();
     Functions["sumproduct"]      = new SumProduct();
     Functions["sumsq"]           = new Sumsq();
     Functions["sumxmy2"]         = new Sumxmy2();
     Functions["sumx2my2"]        = new SumX2mY2();
     Functions["sumx2py2"]        = new SumX2pY2();
     Functions["seriessum"]       = new Seriessum();
     Functions["stdev"]           = new Stdev();
     Functions["stdeva"]          = new Stdeva();
     Functions["stdevp"]          = new StdevP();
     Functions["stdevpa"]         = new Stdevpa();
     Functions["stdev.s"]         = new StdevDotS();
     Functions["stdev.p"]         = new StdevDotP();
     Functions["subtotal"]        = new Subtotal();
     Functions["exp"]             = new Exp();
     Functions["log"]             = new Log();
     Functions["log10"]           = new Log10();
     Functions["ln"]              = new Ln();
     Functions["max"]             = new Max();
     Functions["maxa"]            = new Maxa();
     Functions["median"]          = new Median();
     Functions["min"]             = new Min();
     Functions["mina"]            = new Mina();
     Functions["mod"]             = new Mod();
     Functions["mode"]            = new Mode();
     Functions["mode.sngl"]       = new ModeSngl();
     Functions["mround"]          = new Mround();
     Functions["multinomial"]     = new Multinomial();
     Functions["average"]         = new Average();
     Functions["averagea"]        = new AverageA();
     Functions["averageif"]       = new AverageIf();
     Functions["averageifs"]      = new AverageIfs();
     Functions["round"]           = new Round();
     Functions["rounddown"]       = new Rounddown();
     Functions["roundup"]         = new Roundup();
     Functions["rand"]            = new Rand();
     Functions["randbetween"]     = new RandBetween();
     Functions["rank"]            = new Rank();
     Functions["rank.eq"]         = new RankEq();
     Functions["rank.avg"]        = new RankAvg();
     Functions["percentile"]      = new Percentile();
     Functions["percentile.inc"]  = new PercentileInc();
     Functions["percentile.exc"]  = new PercentileExc();
     Functions["quartile"]        = new Quartile();
     Functions["quartile.inc"]    = new QuartileInc();
     Functions["quartile.exc"]    = new QuartileExc();
     Functions["percentrank"]     = new Percentrank();
     Functions["percentrank.inc"] = new PercentrankInc();
     Functions["percentrank.exc"] = new PercentrankExc();
     Functions["quotient"]        = new Quotient();
     Functions["trunc"]           = new Trunc();
     Functions["tan"]             = new Tan();
     Functions["tanh"]            = new Tanh();
     Functions["atan"]            = new Atan();
     Functions["atan2"]           = new Atan2();
     Functions["atanh"]           = new Atanh();
     Functions["acos"]            = new Acos();
     Functions["acosh"]           = new Acosh();
     Functions["covar"]           = new Covar();
     Functions["covariance.p"]    = new CovarianceP();
     Functions["covariance.s"]    = new CovarianceS();
     Functions["var"]             = new Var();
     Functions["vara"]            = new Vara();
     Functions["var.s"]           = new VarDotS();
     Functions["varp"]            = new VarP();
     Functions["varpa"]           = new Varpa();
     Functions["var.p"]           = new VarDotP();
     Functions["large"]           = new Large();
     Functions["small"]           = new Small();
     Functions["degrees"]         = new Degrees();
     Functions["odd"]             = new Odd();
     Functions["even"]            = new Even();
     // Information
     Functions["isblank"]    = new IsBlank();
     Functions["isnumber"]   = new IsNumber();
     Functions["istext"]     = new IsText();
     Functions["isnontext"]  = new IsNonText();
     Functions["iserror"]    = new IsError();
     Functions["iserr"]      = new IsErr();
     Functions["error.type"] = new ErrorType();
     Functions["iseven"]     = new IsEven();
     Functions["isodd"]      = new IsOdd();
     Functions["islogical"]  = new IsLogical();
     Functions["isna"]       = new IsNa();
     Functions["na"]         = new Na();
     Functions["n"]          = new N();
     Functions["type"]       = new TypeFunction();
     // Logical
     Functions["if"]      = new If();
     Functions["ifs"]     = new Ifs();
     Functions["maxifs"]  = new MaxIfs();
     Functions["minifs"]  = new MinIfs();
     Functions["iferror"] = new IfError();
     Functions["ifna"]    = new IfNa();
     Functions["not"]     = new Not();
     Functions["and"]     = new And();
     Functions["or"]      = new Or();
     Functions["true"]    = new True();
     Functions["false"]   = new False();
     Functions["switch"]  = new Switch();
     Functions["xor"]     = new Xor();
     // Reference and lookup
     Functions["address"]  = new Address();
     Functions["hlookup"]  = new HLookup();
     Functions["vlookup"]  = new VLookup();
     Functions["lookup"]   = new Lookup();
     Functions["match"]    = new Match();
     Functions["row"]      = new Row();
     Functions["rows"]     = new Rows();
     Functions["column"]   = new Column();
     Functions["columns"]  = new Columns();
     Functions["choose"]   = new Choose();
     Functions["index"]    = new RefAndLookup.Index();
     Functions["indirect"] = new Indirect();
     Functions["offset"]   = new Offset();
     // Date
     Functions["date"]             = new Date();
     Functions["datedif"]          = new DateDif();
     Functions["today"]            = new Today();
     Functions["now"]              = new Now();
     Functions["day"]              = new Day();
     Functions["month"]            = new Month();
     Functions["year"]             = new Year();
     Functions["time"]             = new Time();
     Functions["hour"]             = new Hour();
     Functions["minute"]           = new Minute();
     Functions["second"]           = new Second();
     Functions["weeknum"]          = new Weeknum();
     Functions["weekday"]          = new Weekday();
     Functions["days"]             = new Days();
     Functions["days360"]          = new Days360();
     Functions["yearfrac"]         = new Yearfrac();
     Functions["edate"]            = new Edate();
     Functions["eomonth"]          = new Eomonth();
     Functions["isoweeknum"]       = new IsoWeekNum();
     Functions["workday"]          = new Workday();
     Functions["workday.intl"]     = new WorkdayIntl();
     Functions["networkdays"]      = new Networkdays();
     Functions["networkdays.intl"] = new NetworkdaysIntl();
     Functions["datevalue"]        = new DateValue();
     Functions["timevalue"]        = new TimeValue();
     // Database
     Functions["dget"]     = new Dget();
     Functions["dcount"]   = new Dcount();
     Functions["dcounta"]  = new DcountA();
     Functions["dmax"]     = new Dmax();
     Functions["dmin"]     = new Dmin();
     Functions["dsum"]     = new Dsum();
     Functions["daverage"] = new Daverage();
     Functions["dvar"]     = new Dvar();
     Functions["dvarp"]    = new Dvarp();
     //Finance
     Functions["cumipmt"]    = new Cumipmt();
     Functions["cumprinc"]   = new Cumprinc();
     Functions["dollarde"]   = new DollarDe();
     Functions["dollarfr"]   = new DollarFr();
     Functions["ddb"]        = new Ddb();
     Functions["effect"]     = new Effect();
     Functions["fvschedule"] = new FvSchedule();
     Functions["pduration"]  = new Pduration();
     Functions["rri"]        = new Rri();
     Functions["pmt"]        = new Pmt();
     Functions["ppmt"]       = new Ppmt();
     Functions["ipmt"]       = new Ipmt();
     Functions["ispmt"]      = new IsPmt();
     Functions["pv"]         = new Pv();
     Functions["fv"]         = new Fv();
     Functions["npv"]        = new Npv();
     Functions["rate"]       = new Rate();
     Functions["nper"]       = new Nper();
     Functions["nominal"]    = new Nominal();
     Functions["irr"]        = new Irr();
     Functions["mirr"]       = new Mirr();
     Functions["xirr"]       = new Xirr();
     Functions["sln"]        = new Sln();
     Functions["syd"]        = new Syd();
     Functions["xnpv"]       = new Xnpv();
     Functions["coupdays"]   = new Coupdays();
     Functions["coupdaysnc"] = new Coupdaysnc();
     Functions["coupdaybs"]  = new Coupdaybs();
     Functions["coupnum"]    = new Coupnum();
     Functions["coupncd"]    = new Coupncd();
     Functions["couppcd"]    = new Couppcd();
     Functions["price"]      = new Price();
     Functions["yield"]      = new Yield();
     Functions["yieldmat"]   = new Yieldmat();
     Functions["duration"]   = new Duration();
     Functions["disc"]       = new Disc();
     //Engineering
     Functions["bitand"]       = new BitAnd();
     Functions["bitor"]        = new BitOr();
     Functions["bitxor"]       = new BitXor();
     Functions["bitlshift"]    = new BitLshift();
     Functions["bitrshift"]    = new BitRshift();
     Functions["convert"]      = new ConvertFunction();
     Functions["bin2dec"]      = new Bin2Dec();
     Functions["bin2hex"]      = new Bin2Hex();
     Functions["bin2oct"]      = new Bin2Oct();
     Functions["dec2bin"]      = new Dec2Bin();
     Functions["dec2hex"]      = new Dec2Hex();
     Functions["dec2oct"]      = new Dec2Oct();
     Functions["hex2bin"]      = new Hex2Bin();
     Functions["hex2dec"]      = new Hex2Dec();
     Functions["hex2oct"]      = new Hex2Oct();
     Functions["oct2bin"]      = new Oct2Bin();
     Functions["oct2dec"]      = new Oct2Dec();
     Functions["oct2hex"]      = new Oct2Hex();
     Functions["delta"]        = new Delta();
     Functions["erf"]          = new Erf();
     Functions["erf.precise"]  = new ErfPrecise();
     Functions["erfc"]         = new Erfc();
     Functions["erfc.precise"] = new ErfcPrecise();
     Functions["besseli"]      = new BesselI();
     Functions["besselj"]      = new BesselJ();
     Functions["besselk"]      = new BesselK();
     Functions["bessely"]      = new BesselY();
 }
Exemplo n.º 8
0
        public void ExecuteTest1()
        {
            var exp = new Ln(new Number(2));

            Assert.Equal(Math.Log(2), exp.Execute());
        }
Exemplo n.º 9
0
        public void BaseLogarithmOfZeroTest()
        {
            Ln calc = new Ln();

            Assert.Throws <Exception>(() => calc.Calc(-3));
        }
Exemplo n.º 10
0
 public virtual Expression On(Ln e) => On(e as Log);
Exemplo n.º 11
0
 public void NegativeLnTests()
 {
     var calculator = new Ln();
     var result     = calculator.Calculate(-4);
 }
Exemplo n.º 12
0
        public void ExceptionTest()
        {
            var calculator = new Ln();

            Assert.Throws <Exception>(() => calculator.Calculate(0));
        }
Exemplo n.º 13
0
        public void Ln2()
        {
            var ln = new Ln(new Variable("z"));

            SimpleTest(ln, ln);
        }
Exemplo n.º 14
0
 public override Expression On(Ln e)
 {
     return(_.D(e.Argument, x) / e.Argument);
 }
Exemplo n.º 15
0
        public void Zero()
        {
            Ln calc = new Ln();

            Assert.Throws <Exception>(() => calc.Action(0));
        }
Exemplo n.º 16
0
        public void ExceptionLessThanZeroTest(double firstArgument)
        {
            var calculator = new Ln();

            Assert.Throws <Exception>(() => calculator.Calculate(firstArgument));
        }
Exemplo n.º 17
0
        public void Negative()
        {
            Ln calc = new Ln();

            Assert.Throws <Exception>(() => calc.Action(-9));
        }
Exemplo n.º 18
0
        public void ExecuteTestException()
        {
            var exp = new Ln(new Bool(false));

            Assert.Throws <ResultIsNotSupportedException>(() => exp.Execute());
        }
Exemplo n.º 19
0
        private UniversalOperation ParsingAnExpression_VeryHighPriority()
        {
            UniversalOperation result;

            if (MatchSearch('-'))
            {
                result = new Negation(ParsingAnExpression_LowPriority());
            }
            else if (MatchSearch('('))
            {
                result = ParsingAnExpression_LowPriority();

                if (!MatchSearch(')'))
                {
                    throw new System.Exception("Missing ')'");
                }
            }
            else if (MatchSearch('x'))
            {
                return(X);
            }
            else if (position < _currentExpression.Length && char.IsDigit(_currentExpression[position]))
            {
                result = ParsingAnExpression_Number();
            }
            #region Functions
            else if (MatchSearch("sin("))
            {
                result = new Sinus(ParsingAnExpression_LowPriority());
                if (!MatchSearch(')'))
                {
                    throw new System.Exception("Missing ')' for sin");
                }
            }
            else if (MatchSearch("cos("))
            {
                result = new Cosine(ParsingAnExpression_LowPriority());
                if (!MatchSearch(')'))
                {
                    throw new System.Exception("Missing ')' for cos");
                }
            }
            else if (MatchSearch("tan("))
            {
                result = new Tangent(ParsingAnExpression_LowPriority());
                if (!MatchSearch(')'))
                {
                    throw new System.Exception("Missing ')' for tan");
                }
            }
            else if (MatchSearch("sqrt("))
            {
                result = new Sqrt(ParsingAnExpression_LowPriority());
                if (!MatchSearch(')'))
                {
                    throw new System.Exception("Missing ')' for sqrt");
                }
            }
            else if (MatchSearch("exp("))
            {
                result = new Exp(ParsingAnExpression_LowPriority());
                if (!MatchSearch(')'))
                {
                    throw new System.Exception("Missing ')' for exp");
                }
            }
            else if (MatchSearch("ln("))
            {
                result = new Ln(ParsingAnExpression_LowPriority());
                if (!MatchSearch(')'))
                {
                    throw new System.Exception("Missing ')' for ln");
                }
            }
            #endregion
            #region Constants
            else if (MatchSearch("PI"))
            {
                return(new PI());
            }
            else if (MatchSearch("E"))
            {
                return(new E());
            }
            #endregion
            else
            {
                throw new System.Exception("Can't parse character at pos " + position.ToString() + "");
            }
            return(result);
        }
Exemplo n.º 20
0
        public void TestLnUndefined()
        {
            var exp = new Ln(Variable.X);

            Test(exp, ResultType.Undefined);
        }
Exemplo n.º 21
0
 public BuiltInFunctions()
 {
     // Text
     Functions["len"]         = new Len();
     Functions["lower"]       = new Lower();
     Functions["upper"]       = new Upper();
     Functions["left"]        = new Left();
     Functions["right"]       = new Right();
     Functions["mid"]         = new Mid();
     Functions["replace"]     = new Replace();
     Functions["substitute"]  = new Substitute();
     Functions["concatenate"] = new Concatenate();
     Functions["exact"]       = new Exact();
     Functions["find"]        = new Find();
     Functions["proper"]      = new Proper();
     Functions["text"]        = new Text.Text();
     Functions["t"]           = new T();
     // Numbers
     Functions["int"] = new CInt();
     // Math
     Functions["abs"]         = new Abs();
     Functions["cos"]         = new Cos();
     Functions["cosh"]        = new Cosh();
     Functions["power"]       = new Power();
     Functions["sign"]        = new Sign();
     Functions["sqrt"]        = new Sqrt();
     Functions["sqrtpi"]      = new SqrtPi();
     Functions["pi"]          = new Pi();
     Functions["product"]     = new Product();
     Functions["ceiling"]     = new Ceiling();
     Functions["count"]       = new Count();
     Functions["counta"]      = new CountA();
     Functions["countif"]     = new CountIf();
     Functions["fact"]        = new Fact();
     Functions["floor"]       = new Floor();
     Functions["sin"]         = new Sin();
     Functions["sinh"]        = new Sinh();
     Functions["sum"]         = new Sum();
     Functions["sumif"]       = new SumIf();
     Functions["sumproduct"]  = new SumProduct();
     Functions["sumsq"]       = new Sumsq();
     Functions["stdev"]       = new Stdev();
     Functions["stdevp"]      = new StdevP();
     Functions["stdev.s"]     = new Stdev();
     Functions["stdev.p"]     = new StdevP();
     Functions["subtotal"]    = new Subtotal();
     Functions["exp"]         = new Exp();
     Functions["log"]         = new Log();
     Functions["log10"]       = new Log10();
     Functions["ln"]          = new Ln();
     Functions["max"]         = new Max();
     Functions["maxa"]        = new Maxa();
     Functions["min"]         = new Min();
     Functions["mod"]         = new Mod();
     Functions["average"]     = new Average();
     Functions["averagea"]    = new AverageA();
     Functions["averageif"]   = new AverageIf();
     Functions["round"]       = new Round();
     Functions["rounddown"]   = new Rounddown();
     Functions["roundup"]     = new Roundup();
     Functions["rand"]        = new Rand();
     Functions["randbetween"] = new RandBetween();
     Functions["quotient"]    = new Quotient();
     Functions["trunc"]       = new Trunc();
     Functions["tan"]         = new Tan();
     Functions["tanh"]        = new Tanh();
     Functions["atan"]        = new Atan();
     Functions["atan2"]       = new Atan2();
     Functions["var"]         = new Var();
     Functions["varp"]        = new VarP();
     // Information
     Functions["isblank"]   = new IsBlank();
     Functions["isnumber"]  = new IsNumber();
     Functions["istext"]    = new IsText();
     Functions["iserror"]   = new IsError();
     Functions["iserr"]     = new IsErr();
     Functions["iseven"]    = new IsEven();
     Functions["isodd"]     = new IsOdd();
     Functions["islogical"] = new IsLogical();
     Functions["isna"]      = new IsNa();
     Functions["na"]        = new Na();
     Functions["n"]         = new N();
     // Logical
     Functions["if"]   = new If();
     Functions["not"]  = new Not();
     Functions["and"]  = new And();
     Functions["or"]   = new Or();
     Functions["true"] = new True();
     // Reference and lookup
     Functions["address"] = new Address();
     Functions["hlookup"] = new HLookup();
     Functions["vlookup"] = new VLookup();
     Functions["lookup"]  = new Lookup();
     Functions["match"]   = new Match();
     Functions["row"]     = new Row();
     Functions["rows"]    = new Rows()
     {
         SkipArgumentEvaluation = true
     };
     Functions["column"]  = new Column();
     Functions["columns"] = new Columns()
     {
         SkipArgumentEvaluation = true
     };
     Functions["choose"]   = new Choose();
     Functions["index"]    = new Index();
     Functions["indirect"] = new Indirect();
     // Date
     Functions["date"]       = new Date();
     Functions["today"]      = new Today();
     Functions["now"]        = new Now();
     Functions["day"]        = new Day();
     Functions["month"]      = new Month();
     Functions["year"]       = new Year();
     Functions["time"]       = new Time();
     Functions["hour"]       = new Hour();
     Functions["minute"]     = new Minute();
     Functions["second"]     = new Second();
     Functions["weeknum"]    = new Weeknum();
     Functions["weekday"]    = new Weekday();
     Functions["days360"]    = new Days360();
     Functions["yearfrac"]   = new Yearfrac();
     Functions["edate"]      = new Edate();
     Functions["eomonth"]    = new Eomonth();
     Functions["isoweeknum"] = new IsoWeekNum();
     Functions["workday"]    = new Workday();
 }
Exemplo n.º 22
0
        public void TestLnNumber()
        {
            var exp = new Ln(new Number(10));

            Test(exp, ResultType.Number);
        }
Exemplo n.º 23
0
        public void LnToStringTest()
        {
            var exp = new Ln(new Number(5));

            Assert.Equal("ln(5)", exp.ToString(commoonFormatter));
        }
Exemplo n.º 24
0
        public void TestLnComplexNumber()
        {
            var exp = new Ln(new ComplexNumber(10, 10));

            Test(exp, ResultType.ComplexNumber);
        }
Exemplo n.º 25
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);
        }
Exemplo n.º 26
0
        public void TestLnException()
        {
            var exp = new Ln(new Bool(false));

            TestException(exp);
        }
Exemplo n.º 27
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(Ln exp)
 {
     throw new NotSupportedException();
 }
Exemplo n.º 28
0
        public Force(ValBus input)
        {
            this.input = input;


            // Constants
            double SIGMA       = 3.4;
            double EPSILON     = 0.0103;
            double TWELVE      = 12.0;
            double SIX         = 6.0;
            double FOURTEEN    = 14.0;
            double EIGHT       = 8.0;
            double FOURTYEIGHT = 48.0;
            double TWENTYFOUR  = 24.0;
            double FOUR        = 4.0;


            // Constant processes
            var const_sigma       = new Constants(SIGMA);
            var const_epsilon     = new Constants(EPSILON);
            var const_twelve      = new Constants(TWELVE);
            var const_six         = new Constants(SIX);
            var const_fourteen    = new Constants(FOURTEEN);
            var const_eight       = new Constants(EIGHT);
            var const_fourtyeight = new Constants(FOURTYEIGHT);
            var const_twentyfour  = new Constants(TWENTYFOUR);
            var const_four        = new Constants(FOUR);

            // Calculation processes
            // (48*eps*(sig^12/r^14)) - (24*eps*(sig^6/r^8))
            var abs_sigma     = new Abs();
            var ln_sigma      = new Ln();
            var abs_r         = new Abs();
            var ln_r          = new Ln();
            var mul12         = new Mul();
            var mul6          = new Mul();
            var mul14         = new Mul();
            var mul8          = new Mul();
            var exp12         = new Exp();
            var exp6          = new Exp();
            var exp14         = new Exp();
            var exp8          = new Exp();
            var div_12_14     = new Div();
            var div_6_8       = new Div();
            var mul_eps_12_14 = new Mul();
            var mul_eps_6_8   = new Mul();
            var mul_48        = new Mul();
            var mul_24        = new Mul();
            var sub           = new Sub();


            /* NOTE: e^{x*ln(b)} == b^x*/
            abs_r.input     = input;
            abs_sigma.input = const_sigma.output;
            ln_r.input      = abs_r.output;
            ln_sigma.input  = abs_sigma.output;

            mul12.multiplicant = const_twelve.output;
            mul12.multiplier   = ln_sigma.output;
            mul6.multiplicant  = const_six.output;
            mul6.multiplier    = ln_sigma.output;
            exp12.input        = mul12.product;
            exp6.input         = mul6.product;

            mul14.multiplicant = const_fourteen.output;
            mul14.multiplier   = ln_r.output;
            mul8.multiplicant  = const_eight.output;
            mul8.multiplier    = ln_r.output;
            exp14.input        = mul14.product;
            exp8.input         = mul8.product;

            div_12_14.divident = exp12.output;
            div_12_14.divisor  = exp14.output;

            div_6_8.divident = exp6.output;
            div_6_8.divisor  = exp8.output;

            mul_eps_12_14.multiplicant = const_epsilon.output;
            mul_eps_12_14.multiplier   = div_12_14.quotient;

            mul_eps_6_8.multiplicant = const_epsilon.output;
            mul_eps_6_8.multiplier   = div_6_8.quotient;

            mul_48.multiplicant = const_fourtyeight.output;
            mul_48.multiplier   = mul_eps_12_14.product;

            mul_24.multiplicant = const_twentyfour.output;
            mul_24.multiplier   = mul_eps_6_8.product;

            sub.minuend    = mul_48.product;
            sub.subtrahend = mul_24.product;

            output = sub.difference;
        }