public void Visit(Compiled.TermPower elem)
            {
                double baseVal  = ValueOf(elem.Base);
                double exponent = ValueOf(elem.Exponent);

                elem.Value            = Math.Pow(baseVal, exponent);
                elem.Inputs[0].Weight = exponent * Math.Pow(baseVal, exponent - 1);
                elem.Inputs[1].Weight = elem.Value * Math.Log(baseVal);
            }
コード例 #2
0
            public void Visit(Compiled.TermPower elem)
            {
                Debug.Assert(ArgumentIndex == 0 || ArgumentIndex == 1);

                if (ArgumentIndex == 0)
                {
                    var exponent = ValueOf(elem.Exponent);
                    LocalDerivative = elem.Adjoint * exponent * Math.Pow(ValueOf(elem.Base), exponent - 1);
                }
                else
                {
                    var baseValue = ValueOf(elem.Base);
                    LocalDerivative = elem.Adjoint * Math.Pow(baseValue, ValueOf(elem.Exponent)) * Math.Log(baseValue);
                }
            }
コード例 #3
0
            public TapeElement  Visit(TermPower power)
            {
                return(Compile(power, () =>
                {
                    var baseElement = power.Base.Accept(this);
                    var expElement = power.Exponent.Accept(this);
                    var element = new Compiled.TermPower
                    {
                        Inputs = MakeInputEdges(() =>
                        {
                            edges.Add(new InputEdge {
                                Element = baseElement
                            });
                            edges.Add(new InputEdge {
                                Element = expElement
                            });
                        }),
                    };

                    return element;
                }));
            }
コード例 #4
0
            public int Visit(TermPower power)
            {
                return(Compile(power, () =>
                {
                    var baseIndex = power.Base.Accept(this);
                    var expIndex = power.Exponent.Accept(this);
                    var element = new Compiled.TermPower
                    {
                        Base = baseIndex,
                        Exponent = expIndex,
                        Inputs = new Compiled.InputEdge[]
                        {
                            new Compiled.InputEdge {
                                Index = baseIndex
                            },
                            new Compiled.InputEdge {
                                Index = expIndex
                            },
                        },
                    };

                    return element;
                }));
            }
コード例 #5
0
 public void Visit(Compiled.TermPower elem)
 {
     elem.Value = Math.Pow(ValueOf(elem.Base), ValueOf(elem.Exponent));
 }