public void Calculate(double argument, double result) { var calculator = new Cosinus(); var testresult = calculator.Calculate(argument); Assert.AreEqual(result, testresult); }
public void CalculateTest() { IOneArgumentCalculator calculator = new Cosinus(); double result = calculator.Calculate(1); Assert.AreEqual(0.54, result, 0.01); }
public void CalculateTest(double firstValue, double expected) { var calculator = new Cosinus(); var actualResult = calculator.OneArgumentOperation(firstValue); Assert.AreEqual(expected, actualResult); }
public void CalculateTest(double first, double second, double expected) { var calculator = new Cosinus(); var actualresult = calculator.Calculate(first); Assert.AreEqual(expected, actualresult, 0.01); }
public ViewModel() { _plot = new Plots(); Cosinus cosinus = new Cosinus(); cosinus.PropertyChanged += (s, e) => { RaisePropertyChanged("Amplitude_Cos"); }; MyFunction.Add(cosinus); Sinus sinus = new Sinus(); sinus.PropertyChanged += (s, e) => { RaisePropertyChanged("Amplitude_Sin"); }; MyFunction.Add(sinus); Tangens tangens = new Tangens(); tangens.PropertyChanged += (s, e) => { RaisePropertyChanged("Amplitude_Tan"); }; MyFunction.Add(tangens); Cotangens cotangens = new Cotangens(); cotangens.PropertyChanged += (s, e) => { RaisePropertyChanged("Amplitude_Cot"); }; MyFunction.Add(cotangens); plotModel = new PlotModel(); plotModel = _plot._PlotModel; }
public void CosinusTest(double firstValue, double expected) { var calculator = new Cosinus(); var actualResult = calculator.Calculate(firstValue); Assert.AreEqual(expected, actualResult); }
public void CosinusTest(double first, double expected) { var calc = new Cosinus(); double result = calc.Calculate(first); Assert.AreEqual(expected, result); }
public void CosinusTest() { Cosinus calculator = new Cosinus(); double result = calculator.Calculate(0); Assert.AreEqual(1, result); }
public void CalculateCosinusTest(double firstValue, double expected) { IOneArgumentCalculator calculator = new Cosinus(); double result = calculator.Calculate(firstValue); Assert.AreEqual(expected, result); }
public override object Clone() { var returnObject = new Cosinus { FunctionName = string.Copy(FunctionName), Middle = Middle }; return(returnObject); }
public FonctionNumTest() { Numeric[] val1 = new Numeric[1]; Numeric[] val2 = new Numeric[2]; val1[0] = new Numeric("9"); val2[0] = new Numeric("9"); val2[1] = new Numeric("2"); ab = new Absolu(val1); ar = new Arrondi(val1); moy = new Moyenne(val2); p = new Puissance(val2); r = new Racine(val1); at = new Atan(val1); cos = new Cosinus(val1); tan = new Tangente(val1); tod = new ToDegree(val1); tor = new ToRadiant(val1); }
public static void PickedACS() { Console.WriteLine("Pick product and an user for new predicted rating"); Console.WriteLine("Pick the userID"); UserChoice.choiceUserId = int.Parse(Console.ReadLine()); List<int> ratedProduct = FileReader.DictionaryData[UserChoice.choiceUserId].Select(x => x.Item1).ToList(); ratedProduct.Sort(); foreach (var productId in FileReader.GetItemList()) { if (!ratedProduct.Contains((int)productId)) { Cosinus.ACS((int)productId); if (Normalization.NormalizedDictionary.Count() == 0) { Normalization.Normalize(UserChoice.choiceUserId); } Console.WriteLine("Predicted result for productId: " + productId + " predicted rating is " + Prediction.CalculatePrediction(UserChoice.choiceUserId, (int)productId)); } } Console.ReadLine(); }
public Node <INode> GetNode(string nodeName) { switch (nodeName) { case Absolute.NAME: INode nodeAbsolute = new Absolute() as INode; return(new Node <INode>(nodeAbsolute)); case Approx.NAME: INode nodeAprox = new Approx() as INode; return(new Node <INode>(nodeAprox)); case ArcCos.NAME: INode nodeArcCos = new ArcCos() as INode; return(new Node <INode>(nodeArcCos)); case ArcSin.NAME: INode nodeArcSin = new ArcSin() as INode; return(new Node <INode>(nodeArcSin)); case ArcTan2.NAME: INode nodeArcTan2 = new ArcTan2() as INode; return(new Node <INode>(nodeArcTan2)); case Ceil.NAME: INode nodeCeil = new Ceil() as INode; return(new Node <INode>(nodeCeil)); case CeilToInt.NAME: INode nodeCeilToInt = new CeilToInt() as INode; return(new Node <INode>(nodeCeilToInt)); case Clamp.NAME: INode nodeClamp = new Clamp() as INode; return(new Node <INode>(nodeClamp)); case Clamp01.NAME: INode nodeClamp01 = new Clamp01() as INode; return(new Node <INode>(nodeClamp01)); case ClosestPowerOf2.NAME: INode nodeClosestPowerOf2 = new ClosestPowerOf2() as INode; return(new Node <INode>(nodeClosestPowerOf2)); case Cosinus.NAME: INode nodeCosinus = new Cosinus() as INode; return(new Node <INode>(nodeCosinus)); case DeltaAngle.NAME: INode nodeDeltaAngle = new DeltaAngle() as INode; return(new Node <INode>(nodeDeltaAngle)); case Exp.NAME: INode nodeExp = new Exp() as INode; return(new Node <INode>(nodeExp)); case Floor.NAME: INode nodeFloor = new Floor() as INode; return(new Node <INode>(nodeFloor)); case FloorToInt.NAME: INode nodeFloorToInt = new FloorToInt() as INode; return(new Node <INode>(nodeFloorToInt)); case Lerp.NAME: INode nodeLerp = new Lerp() as INode; return(new Node <INode>(nodeLerp)); case LerpAngle.NAME: INode nodeLerpAngle = new LerpAngle() as INode; return(new Node <INode>(nodeLerpAngle)); case Log10.NAME: INode nodeLog10 = new Log10() as INode; return(new Node <INode>(nodeLog10)); case Logarithm.NAME: INode nodeLogarithm = new Logarithm() as INode; return(new Node <INode>(nodeLogarithm)); case Sinus.NAME: INode nodeSinus_ = new Sinus() as INode; return(new Node <INode>(nodeSinus_)); case Max.NAME: INode nodeMax = new Max() as INode; return(new Node <INode>(nodeMax)); case Min.NAME: INode nodeMin = new Min() as INode; return(new Node <INode>(nodeMin)); case MoveTowards.NAME: INode nodeMoveTowards = new MoveTowards() as INode; return(new Node <INode>(nodeMoveTowards)); case MoveTowardsAngle.NAME: INode nodeMoveTowardsAngle = new MoveTowardsAngle() as INode; return(new Node <INode>(nodeMoveTowardsAngle)); case NextPowerOfTwo.NAME: INode nodeNextPowerOfTwo = new NextPowerOfTwo() as INode; return(new Node <INode>(nodeNextPowerOfTwo)); case PerlinNoise.NAME: INode nodePerlinNoise = new PerlinNoise() as INode; return(new Node <INode>(nodePerlinNoise)); case PingPong.NAME: INode nodePingPong = new PingPong() as INode; return(new Node <INode> (nodePingPong)); case Pow.NAME: INode nodePow = new Pow() as INode; return(new Node <INode>(nodePow)); case SquareRoot.NAME: INode nodeSqrt = new SquareRoot() as INode; return(new Node <INode>(nodeSqrt)); case Tan.NAME: INode nodeTan = new Tan() as INode; return(new Node <INode>(nodeTan)); case Random.NAME: INode nodeRandom = new Random() as INode; return(new Node <INode>(nodeRandom)); default: return(null); } }
/// <summary> /// Function expression /// </summary> /// <param name="context"></param> /// <returns></returns> public override Function VisitFunction(CalculatorParser.FunctionContext context) { Function res = null; //Trigonometric functions if (FunctionMap[context.fun.Type] is Sinus) { res = new Sinus(Visit(context.expr())); } if (FunctionMap[context.fun.Type] is Cosinus) { res = new Cosinus(Visit(context.expr())); } if (FunctionMap[context.fun.Type] is Tangens) { res = new Tangens(Visit(context.expr())); } if (FunctionMap[context.fun.Type] is Cotangens) { res = new Cotangens(Visit(context.expr())); } //Elementary functions if (FunctionMap[context.fun.Type] is Sqrt) { res = new Sqrt(Visit(context.expr())); } if (FunctionMap[context.fun.Type] is Logarithm) { res = new Logarithm(Visit(context.expr())); } if (FunctionMap[context.fun.Type] is Exponenta) { res = new Exponenta(Visit(context.expr())); } //Inverse Trigonometric functions if (FunctionMap[context.fun.Type] is ArcSinus) { res = new ArcSinus(Visit(context.expr())); } if (FunctionMap[context.fun.Type] is ArcCosinus) { res = new ArcCosinus(Visit(context.expr())); } if (FunctionMap[context.fun.Type] is ArcTangens) { res = new ArcTangens(Visit(context.expr())); } if (FunctionMap[context.fun.Type] is ArcCotangens) { res = new ArcCotangens(Visit(context.expr())); } //Hyperbolic functions if (FunctionMap[context.fun.Type] is HypSinus) { res = new HypSinus(Visit(context.expr())); } if (FunctionMap[context.fun.Type] is HypCosinus) { res = new HypCosinus(Visit(context.expr())); } if (FunctionMap[context.fun.Type] is HypTangens) { res = new HypTangens(Visit(context.expr())); } if (FunctionMap[context.fun.Type] is HypCotangens) { res = new HypCotangens(Visit(context.expr())); } return(res); }
public void CalculateTestExceptionTest() { IOneArgumentCalculator calculator = new Cosinus(); Assert.Throws <Exception>(() => calculator.Calculate(3)); }
private void ParseNextPart(ref OperationClass a, ref bool isExpressionNotEnded) { if (l < expression.Length) { string s = expression.Substring(l); if (Regex.IsMatch(s, digits, RegexOptions.IgnoreCase)) { Match digit = Regex.Match(s, digits, RegexOptions.IgnoreCase); s = s.Substring(0, digit.Length); a = new Value(float.Parse(s)); l += digit.Length; } else if (Regex.IsMatch(s, cos, RegexOptions.IgnoreCase)) { Match digit = Regex.Match(s, cos, RegexOptions.IgnoreCase); l += digit.Length; OperationClass b = new Value(0); Parse(ref b); a = new Cosinus(b); } else if (Regex.IsMatch(s, sin, RegexOptions.IgnoreCase)) { Match digit = Regex.Match(s, sin, RegexOptions.IgnoreCase); l += digit.Length; OperationClass b = new Value(0); Parse(ref b); a = new Sinus(b); } else if (Regex.IsMatch(s, tangent, RegexOptions.IgnoreCase)) { Match digit = Regex.Match(s, tangent, RegexOptions.IgnoreCase); l += digit.Length; OperationClass b = new Value(0); Parse(ref b); a = new Tangent(b); } else if (Regex.IsMatch(s, plus, RegexOptions.IgnoreCase)) { Match digit = Regex.Match(s, plus, RegexOptions.IgnoreCase); l += digit.Length; Plus b = new Plus(); b.FirstOperand = a; ParseNextPart(ref b.SecondOperand, ref isExpressionNotEnded); a = b; } else if (Regex.IsMatch(s, minus, RegexOptions.IgnoreCase)) { Match digit = Regex.Match(s, minus, RegexOptions.IgnoreCase); l += digit.Length; Minus b = new Minus(); b.FirstOperand = a; ParseNextPart(ref b.SecondOperand, ref isExpressionNotEnded); a = b; } else if (Regex.IsMatch(s, multipl, RegexOptions.IgnoreCase)) { Match digit = Regex.Match(s, multipl, RegexOptions.IgnoreCase); l += digit.Length; Multiplication b = new Multiplication(); ParseNextPart(ref b.SecondOperand, ref isExpressionNotEnded); if (a.Priority > 2) { BasicOperations buff = a as BasicOperations; b.FirstOperand = buff.SecondOperand; buff.SecondOperand = b; a = buff; } else { b.FirstOperand = a; a = b; } } else if (Regex.IsMatch(s, divide, RegexOptions.IgnoreCase)) { Match digit = Regex.Match(s, divide, RegexOptions.IgnoreCase); l += digit.Length; Division b = new Division(); ParseNextPart(ref b.SecondOperand, ref isExpressionNotEnded); if (a.Priority > 2) { BasicOperations buff = a as BasicOperations; b.FirstOperand = buff.SecondOperand; buff.SecondOperand = b; a = buff; } else { b.FirstOperand = a; a = b; } } else if (Regex.IsMatch(s, power, RegexOptions.IgnoreCase)) { Match digit = Regex.Match(s, power, RegexOptions.IgnoreCase); l += digit.Length; Power b = new Power(); ParseNextPart(ref b.SecondOperand, ref isExpressionNotEnded); if (a.Priority == -3) { b.FirstOperand = a; a = b; } //BasicOperations buff = a as BasicOperations; //b.FirstOperand = buff.SecondOperand; //buff.SecondOperand = b; //a = buff; } else if (Regex.IsMatch(s, e, RegexOptions.IgnoreCase)) { Match digit = Regex.Match(s, e, RegexOptions.IgnoreCase); l += digit.Length; a = new E(); } else if (Regex.IsMatch(s, pi, RegexOptions.IgnoreCase)) { Match digit = Regex.Match(s, pi, RegexOptions.IgnoreCase); l += digit.Length; a = new PI(); } else if (Regex.IsMatch(s, openingbracket, RegexOptions.IgnoreCase)) { Match digit = Regex.Match(s, openingbracket, RegexOptions.IgnoreCase); l += digit.Length; Parse(ref a); } else if (Regex.IsMatch(s, closingbracket, RegexOptions.IgnoreCase)) { Match digit = Regex.Match(s, closingbracket, RegexOptions.IgnoreCase); l += digit.Length; if (Regex.IsMatch(s, power, RegexOptions.IgnoreCase)) { digit = Regex.Match(s, power, RegexOptions.IgnoreCase); l += digit.Length; Power b = new Power(); ParseNextPart(ref b.SecondOperand, ref isExpressionNotEnded); b.FirstOperand = a; a = b; } isExpressionNotEnded = false; } else if (Regex.IsMatch(s, t, RegexOptions.IgnoreCase)) { Match digit = Regex.Match(s, t, RegexOptions.IgnoreCase); l += digit.Length; a = new Tparam(); } } else { isExpressionNotEnded = false; } }