Exemplo n.º 1
0
        public static void RegisterTheorems(ILibrary library)
        {
            Analysis.DerivativeTransformation.Provider.Add(
                new Analysis.DerivativeTransformation(_entityId,
                                                      delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs)
            {
                Signal[] outputs             = new Signal[manipulatedInputs.Count];
                ReadOnlySignalSet cotangents = StdBuilder.Cotangent(port.InputSignals);
                for (int i = 0; i < outputs.Length; i++)
                {
                    outputs[i] = Std.Multiply(port.OutputSignals[i], cotangents[i], manipulatedInputs[i]);
                }
                return(StdBuilder.Negate(outputs));
            }));

            MathIdentifier   typeId = new MathIdentifier("TrigonometricSubstitute", "Std");
            ITheoremProvider basicProvider;

            if (!library.TryLookupTheoremType(typeId, out basicProvider))
            {
                basicProvider = Binder.GetInstance <ITransformationTheoremProvider, MathIdentifier>(typeId);
                library.AddTheoremType(basicProvider);
            }
            ((ITransformationTheoremProvider)basicProvider).Add(
                new BasicTransformation(_entityId.DerivePostfix("TrigonometricSubstitute"), typeId,
                                        delegate() { return(new Pattern(new EntityCondition(_entityId))); },
                                        delegate(Port port) { return(ManipulationPlan.DoAlter); },
                                        delegate(Port port, SignalSet transformedInputs, bool hasTransformedInputs)
            {
                return(StdBuilder.Invert(StdBuilder.Sine(transformedInputs)));
                //Signal[] ret = new Signal[transformedInputs.Count];
                //for(int i = 0; i < ret.Length; i++)
                //    ret[i] = Std.Invert(Std.Sine(transformedInputs[i]));
                //return ret;
            }));
        }