public void Lb() { var log = new Lb(new Number(2)); var expected = new Number(1); SimpleTest(log, expected); }
public void CloneTest() { var exp = new Lb(new Number(5)); var clone = exp.Clone(); Assert.Equal(exp, clone); }
private static void LoadDownLightsSprite() { Lb.Invoke(new Action(() => Lb.Text = "TrafficLights .. " + "img\\Lights\\DownLights.spr")); SpriteLibDownLights[0] = new Bitmap(Image.FromFile("img\\Lights\\Red.png")); SpriteLibDownLights[1] = new Bitmap(Image.FromFile("img\\Lights\\Yellow.png")); SpriteLibDownLights[2] = new Bitmap(Image.FromFile("img\\Lights\\Green.png")); Thread.Sleep(_delay * 5); }
private static void LoadUpSprite() { for (int i = 0; i < SpriteLibUp.Length; i++) { Lb.Invoke(new Action(() => Lb.Text = "Up .. " + CarFileName[i])); Thread.Sleep(_delay); _tmpBitmap = new Bitmap(Image.FromFile(CarFileName[i])); SpriteLibUp[i] = _tmpBitmap; } }
private static void LoadPeopleLibLeft() { for (int i = 0; i < SpriteLibLeftPeople1.Length; i++) { Lb.Invoke(new Action(() => Lb.Text = "Left .. " + PeopleFileName1[i])); Thread.Sleep(_delay); SpriteLibLeftPeople1[i] = new Bitmap(Image.FromFile(PeopleFileName1[i])); SpriteLibLeftPeople2[i] = new Bitmap(Image.FromFile(PeopleFileName2[i])); } }
private static void LoadLeftSprite() { for (int i = 0; i < SpriteLibLeft.Length; i++) { Lb.Invoke(new Action(() => Lb.Text = "Left .. " + CarFileName[i])); Thread.Sleep(_delay); _tmpBitmap = new Bitmap(Image.FromFile(CarFileName[i])); _tmpBitmap.RotateFlip(RotateFlipType.Rotate270FlipNone); SpriteLibLeft[i] = _tmpBitmap; } }
/// <summary> /// Analyzes the specified expression. /// </summary> /// <param name="exp">The expression.</param> /// <returns> /// The result of analysis. /// </returns> public override IExpression Analyze(Lb exp) { if (!Helpers.HasVariable(exp, Variable)) { return(new Number(0)); } var ln = new Ln(new Number(2)); var mul = new Mul(exp.Argument.Clone(), ln); var div = new Div(exp.Argument.Clone().Analyze(this), mul); return(div); }
private static void LoadLeftLightsSprite() { Lb.Invoke(new Action(() => Lb.Text = "TrafficLights .. " + "img\\Lights\\LeftLights.spr")); _tmpBitmap = new Bitmap(Image.FromFile("img\\Lights\\Red.png")); _tmpBitmap.RotateFlip(RotateFlipType.Rotate90FlipNone); SpriteLibLeftLights[0] = _tmpBitmap; _tmpBitmap = new Bitmap(Image.FromFile("img\\Lights\\Yellow.png")); _tmpBitmap.RotateFlip(RotateFlipType.Rotate90FlipNone); SpriteLibLeftLights[1] = _tmpBitmap; _tmpBitmap = new Bitmap(Image.FromFile("img\\Lights\\Green.png")); _tmpBitmap.RotateFlip(RotateFlipType.Rotate90FlipNone); SpriteLibLeftLights[2] = _tmpBitmap; Thread.Sleep(_delay * 5); }
private static void LoadPeopleLibDown() { for (int i = 0; i < SpriteLibLeftPeople1.Length; i++) { Lb.Invoke(new Action(() => Lb.Text = "Down .. " + PeopleFileName1[i])); Thread.Sleep(_delay); _tmpBitmap = new Bitmap(Image.FromFile(PeopleFileName1[i])); _tmpBitmap.RotateFlip(RotateFlipType.Rotate270FlipNone); SpriteLibDownPeople1[i] = _tmpBitmap; _tmpBitmap = new Bitmap(Image.FromFile(PeopleFileName2[i])); _tmpBitmap.RotateFlip(RotateFlipType.Rotate270FlipNone); SpriteLibDownPeople2[i] = _tmpBitmap; } }
//##################################################################### // Get all business in businesses linked to groups attached to the user //##################################################################### public IQueryable <Business> QueryBusinessViewableByUser(UserSessionModel user, bool showUnallocated) { IQueryable <Business> query; if (user == null || user.UserId == 0 || user.UserTypeId >= UserTypeEnum.DaikinSuperUser) { query = this.Businesses; } else { //##################################################################### // Show all businesses user can see including his/her own //##################################################################### //var results = this.QueryUsersViewableByUser(user, showUnallocated).ToList(); //var businesses = (from b in this.Businesses // select b).ToList(); //var test = (from b in businesses // join u in results // on b.BusinessId equals u.BusinessId into ub // from us in ub.DefaultIfEmpty() // select b).ToList(); //var test2 = (from u in test // join b in businesses // on u.BusinessId equals b.BusinessId // select b).Distinct().ToList(); //query = (from b in businesses // join u in results // on b.BusinessId equals u.BusinessId into ub // from u in ub.DefaultIfEmpty() // where u.BusinessId == b.BusinessId || b.BusinessId == user.BusinessId // select b // ).Distinct().AsQueryable(); query = (from b in this.Businesses join u in QueryUsersViewableByUser(user, showUnallocated) on b.BusinessId equals u.BusinessId into Lb from u in Lb.DefaultIfEmpty() where b.BusinessId == u.BusinessId || b.BusinessId == user.BusinessId select b).Distinct(); } return(query); }
public void ExecuteTestException() { var exp = new Lb(new Bool(false)); Assert.Throws <ResultIsNotSupportedException>(() => exp.Execute()); }
/// <summary> /// Analyzes the specified expression. /// </summary> /// <param name="exp">The expression.</param> /// <returns>The result of analysis.</returns> public string Analyze(Lb exp) { return(ToString(exp, "lb({0})")); }
public void ExecuteTest() { var exp = new Lb(new Number(2)); Assert.Equal(Math.Log(2, 2), exp.Execute()); }
public void Lb2() { var log = new Lb(new Number(3)); SimpleTest(log, log); }
/// <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 TestLbUndefined() { var exp = new Lb(Variable.X); Test(exp, ResultType.Undefined); }
public void LbPartialDerivativeTest1() { // lb(2xy) var exp = new Lb(new Mul(new Mul(new Number(2), new Variable("x")), new Variable("y"))); var deriv = Differentiate(exp); Assert.Equal("(2 * 1 * y) / (2 * x * y * ln(2))", deriv.ToString()); }
public void LbPartialDerivativeTest2() { // lb(2xy) var exp = new Lb(new Variable("x")); var deriv = Differentiate(exp, new Variable("y")); Assert.Equal("0", deriv.ToString()); }
public void LbDerivativeTest1() { var exp = new Lb(new Mul(new Number(2), new Variable("x"))); var deriv = Differentiate(exp); Assert.Equal("(2 * 1) / (2 * x * ln(2))", deriv.ToString()); }
public void LbDerivativeTest2() { // lb(2x) var num = new Number(2); var x = new Variable("x"); var mul = new Mul(num, x); var exp = new Lb(mul); var deriv = Differentiate(exp); Assert.Equal("(2 * 1) / (2 * x * ln(2))", deriv.ToString()); num.Value = 3; Assert.Equal("lb(3 * x)", exp.ToString()); Assert.Equal("(2 * 1) / (2 * x * ln(2))", deriv.ToString()); }
public void TestLbException() { var exp = new Lb(new Bool(false)); TestException(exp); }
public void TestLbNumber() { var exp = new Lb(new Number(10)); Test(exp, ResultType.Number); }
public void LbToStringTest() { var exp = new Lb(new Number(5)); Assert.Equal("lb(5)", exp.ToString(commoonFormatter)); }
/// <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(Lb exp) { throw new NotSupportedException(); }
/// <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; } var diff = exp as DifferentParametersExpression; if (diff != null) diff.ParametersCount = token.CountOfParams; return exp; }