public void CalculateTest(double firstValue, double expected) { var calculator = new ArcTan(); var actualResult = calculator.Calculate(firstValue); Assert.AreEqual(expected, actualResult, 0.0001); }
static void Main() { //var d = new SampleData1(0); var d = new SampleData2(2, true); //IActivationFunction sig = new Sigmoid(); IActivationFunction af = new ArcTan(); Network network = d.network; network.activationFunc = af; network.initializeWeights(); Console.WriteLine("after initialization"); network.PrintNetwork(); for (int j = 0; j < 10000; j++) { for (int i = 0; i < d.GetSize(); i++) { network.forwardPropogate(d.inputList[i]); network.backPropogate(d.outputList[i]); } } Console.WriteLine("after training"); network.PrintNetwork(); network.Test(d.Test(1)); Console.ReadKey(); }
static void TestAll(Func <double, double> func) { string n = func.Method.Name; TestCommon(func, TestMin, TestMax, n); TestCommon((double y, double x) => ArcTan.Atan2_1(func, y, x), TestMin, TestMax, n + "-atan21"); TestCommon((double y, double x) => ArcTan.Atan2_2(func, y, x), TestMin, TestMax, n + "-atan22"); }
IEnumerable <TestItem> GetTestItems() { yield return(new TestItem { Delta = 0.0136638037737241, Name = nameof(ArcTan.AtanSO1), Method = Pack(ArcTan.AtanSO1) }); yield return(new TestItem { Delta = 0.0935295762042112, Name = nameof(ArcTan.AtanMac), Method = Pack((double a) => ArcTan.AtanMac(a)) }); yield return(new TestItem { Delta = 0.0658025452458654, Name = nameof(ArcTan.AtanMac) + "-16", Method = Pack((double a) => ArcTan.AtanMac(a, 16)) }); yield return(new TestItem { Delta = 0.0569347297414578, Name = nameof(ArcTan.AtanMac) + "-32", Method = Pack((double a) => ArcTan.AtanMac(a, 32)) }); yield return(new TestItem { Delta = 0.00226640192840601, Name = nameof(ArcTan.AtanActon), Method = Pack((double a) => ArcTan.AtanActon(a)) }); yield return(new TestItem { Delta = 3.45821481589903E-08, Name = nameof(ArcTan.AtanActon) + "-16", Method = Pack((double a) => ArcTan.AtanActon(a, 16)) }); yield return(new TestItem { Delta = 5.04457586814056E-14, Name = nameof(ArcTan.AtanActon) + "-32", Method = Pack((double a) => ArcTan.AtanActon(a, 32)) }); yield return(new TestItem { Delta = 5.64583343687364E-08, Name = nameof(ArcTan.AtanAms), Method = Pack((double a) => ArcTan.AtanAms(a)) }); yield return(new TestItem { Delta = 122.793568849762, Name = nameof(ArcTan.Atanfdlibm), Method = Pack(ArcTan.Atanfdlibm) }); }
public virtual TResult Visit(BaseExpression expression) { return(expression switch { Phi a => Visit(a), Increment a => Visit(a), Decrement a => Visit(a), ErrorExpression a => Visit(a), Bracketed a => Visit(a), Abs a => Visit(a), Sqrt a => Visit(a), Sine a => Visit(a), Cosine a => Visit(a), Tangent a => Visit(a), ArcSine a => Visit(a), ArcCos a => Visit(a), ArcTan a => Visit(a), PostIncrement a => Visit(a), PreIncrement a => Visit(a), PostDecrement a => Visit(a), PreDecrement a => Visit(a), Add a => Visit(a), Subtract a => Visit(a), Multiply a => Visit(a), Divide a => Visit(a), Modulo a => Visit(a), Negate a => Visit(a), Exponent a => Visit(a), Or a => Visit(a), And a => Visit(a), Not a => Visit(a), Factorial a => Visit(a), Variable a => Visit(a), ConstantNumber a => Visit(a), ConstantString a => Visit(a), EqualTo a => Visit(a), NotEqualTo a => Visit(a), GreaterThan a => Visit(a), GreaterThanEqualTo a => Visit(a), LessThan a => Visit(a), LessThanEqualTo a => Visit(a), _ => VisitUnknown(expression) });
protected override bool Visit(ArcTan app) => StaticFalse(app);
protected override Type Visit(ArcTan app) => UnaryNumeric(app, app.Parameter, true, false);
[NotNull] protected abstract TResult Visit([NotNull] ArcTan app);
protected override BaseExpression Visit(ArcTan app) { using (AppendLine("ATAN")) return(base.Visit(app)); }
[NotNull] protected virtual BaseExpression Visit([NotNull] ArcTan app) { return(new ArcTan(Visit(app.Parameter))); }
protected override IDataFlowGraphExpressionNode Visit(ArcTan app) { return(VisitUnary(new UnaryOp(Guid.NewGuid(), "atan", Visit(app.Parameter), a => new ArcTan(a)))); }
protected override bool Visit(ArcTan app) => Visit(app.Parameter);
protected override IEnumerable <BaseStatement> Visit(ArcTan app) => Unary(app, a => new ArcTan(a));
protected override bool Visit(ArcTan app) => Visit(app.Parameter) && _level >= YololChip.Professional;