public static ITheorem[] BuildTheorems(Context context) { ITheorem[] theorems = new ITheorem[2]; theorems[0] = new Analysis.DerivativeTransformation(context.Library.LookupEntity(_entityId), delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs) { int cnt = manipulatedInputs.Count - 1; Builder b = context.Builder; Signal[] multiplySignals = new Signal[cnt]; Signal[] addSignals = new Signal[cnt]; for (int i = 0; i < cnt; i++) { multiplySignals[i] = port.InputSignals[i + 1]; } Signal left = b.DivideSimplified(manipulatedInputs[0], multiplySignals); for (int i = 0; i < cnt; i++) { for (int j = 0; j < cnt; j++) { multiplySignals[j] = i == j ? b.Square(port.InputSignals[j + 1]) : port.InputSignals[j + 1]; } Signal num = b.MultiplySimplified(port.InputSignals[0], manipulatedInputs[i + 1]); addSignals[i] = b.DivideSimplified(num, multiplySignals); } return(new SignalSet(b.SubtractSimplified(left, addSignals))); }); theorems[1] = new Algebra.AutoSimplifyTransformation(context.Library.LookupEntity(_entityId), delegate(Port port) { // TODO return(ManipulationPlan.DoAlter); }, delegate(Port port, SignalSet manipulatedInputs, bool hasManipulatedInputs) { if (SimplifyFactors(manipulatedInputs) || hasManipulatedInputs) { if (manipulatedInputs.Count == 0) { return(new SignalSet(StdPackage.Structures.IntegerValue.ConstantMultiplicativeIdentity(context))); } if (manipulatedInputs.Count == 1) { return(manipulatedInputs); } return(new SignalSet(context.Builder.Divide(manipulatedInputs))); } else { return(port.OutputSignals); } }); return(theorems); }
public static ITheorem[] BuildTheorems(Context context) { ITheorem[] theorems = new ITheorem[2]; theorems[0] = new Analysis.DerivativeTransformation(_entityId, delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs) { int cnt = manipulatedInputs.Count; Signal[] addSignals = new Signal[cnt]; Signal[] multiplySignals = new Signal[cnt]; for (int i = 0; i < cnt; i++) { for (int j = 0; j < cnt; j++) { multiplySignals[j] = i == j ? manipulatedInputs[j] : port.InputSignals[j]; } addSignals[i] = context.Builder.MultiplySimplified(multiplySignals); } return(new SignalSet(context.Builder.AddSimplified(addSignals))); }); theorems[1] = new Algebra.AutoSimplifyTransformation(_entityId, delegate(Port port) { // TODO return(ManipulationPlan.DoAlter); }, delegate(Port port, SignalSet manipulatedInputs, bool hasManipulatedInputs) { if (SimplifyFactors(manipulatedInputs) || hasManipulatedInputs) { if (manipulatedInputs.Count == 0) { return(new SignalSet(StdPackage.Structures.IntegerValue.ConstantMultiplicativeIdentity(context))); } if (manipulatedInputs.Count == 1) { return(manipulatedInputs); } return(new SignalSet(context.Builder.Multiply(manipulatedInputs))); } else { return(port.OutputSignals); } }); return(theorems); }
//public static Signal[] SimplifyOperands(List<Signal> signals) //{ // if(signals.Count>0 && Std.IsConstantOne(signals[0])) // return new Signal[] { signals[0] }; // for(int i = signals.Count - 1; i > 0; i--) //don't touch first item // { // if(Std.IsConstantZero(signals[i])) // return new Signal[] { IntegerValue.ConstantOne(signals[i].Context) }; // if(Std.IsConstantOne(signals[i])) // signals.RemoveAt(i); // } // return signals.ToArray(); //} public static ITheorem[] BuildTheorems(Context context) { ITheorem[] theorems = new ITheorem[1]; //theorems[0] = new Analysis.DerivativeTransformation("PowerDerivative", "Std", context.Library.LookupEntity("Power", "Std"), // delegate(Port port, Signal[] derivedInputSignals) // { // Signal innerA = derivedInputSignals[1] * context.Builder.NaturalLogarithm(port.InputSignals[0]); // Signal innerB = (port.InputSignals[1] * derivedInputSignals[0]) / port.InputSignals[0]; // return port.OutputSignals[0] * (innerA + innerB); // }); theorems[0] = new Algebra.AutoSimplifyTransformation(_entityId, delegate(Port port) { // TODO return(ManipulationPlan.DoAlter); }, delegate(Port port, SignalSet manipulatedInputs, bool hasManipulatedInputs) { if (Std.IsConstantMultiplicativeIdentity(manipulatedInputs[0])) { return(new SignalSet(manipulatedInputs[0])); } if (Std.IsConstantMultiplicativeIdentity(manipulatedInputs[1])) { return(new SignalSet(manipulatedInputs[0])); } if (Std.IsConstantAdditiveIdentity(manipulatedInputs[1])) { return(new SignalSet(IntegerValue.ConstantOne(port.Context))); } if (hasManipulatedInputs) { return(port.Entity.InstantiatePort(port.Context, manipulatedInputs).OutputSignals); } else { return(port.OutputSignals); } }); return(theorems); }
public static ITheorem[] BuildTheorems(Context context) { ITheorem[] theorems = new ITheorem[2]; theorems[0] = new Analysis.DerivativeTransformation(context.Library.LookupEntity(_entityId), delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs) { return(new SignalSet(manipulatedInputs)); }); theorems[1] = new Algebra.AutoSimplifyTransformation(context.Library.LookupEntity(_entityId), delegate(Port port) { return(ManipulationPlan.DoAlter); }, delegate(Port port, SignalSet manipulatedInputs, bool hasManipulatedInputs) { return(new SignalSet(manipulatedInputs)); }); return(theorems); }
public static ITheorem[] BuildTheorems(Context context) { ITheorem[] theorems = new ITheorem[2]; theorems[0] = new Analysis.DerivativeTransformation(_entityId, delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs) { return(new SignalSet(context.Builder.AddSimplified(manipulatedInputs))); }); theorems[1] = new Algebra.AutoSimplifyTransformation(_entityId, delegate(Port port) { // TODO return(ManipulationPlan.DoAlter); }, delegate(Port port, SignalSet manipulatedInputs, bool hasManipulatedInputs) { if (SimplifySummands(manipulatedInputs) || hasManipulatedInputs) { if (manipulatedInputs.Count == 0) { return(new SignalSet(StdPackage.Structures.IntegerValue.ConstantAdditiveIdentity(context))); } if (manipulatedInputs.Count == 1) { return(manipulatedInputs); } return(new SignalSet(context.Builder.Add(manipulatedInputs))); } else { return(port.OutputSignals); } }); return(theorems); }
//public static Signal[] SimplifyOperands(List<Signal> signals) //{ // if(signals.Count>0 && Std.IsConstantOne(signals[0])) // return new Signal[] { signals[0] }; // for(int i = signals.Count - 1; i > 0; i--) //don't touch first item // { // if(Std.IsConstantZero(signals[i])) // return new Signal[] { IntegerValue.ConstantOne(signals[i].Context) }; // if(Std.IsConstantOne(signals[i])) // signals.RemoveAt(i); // } // return signals.ToArray(); //} public static ITheorem[] BuildTheorems(Context context) { ITheorem[] theorems = new ITheorem[1]; //theorems[0] = new Analysis.DerivativeTransformation("PowerDerivative", "Std", context.Library.LookupEntity("Power", "Std"), // delegate(Port port, Signal[] derivedInputSignals) // { // Signal innerA = derivedInputSignals[1] * context.Builder.NaturalLogarithm(port.InputSignals[0]); // Signal innerB = (port.InputSignals[1] * derivedInputSignals[0]) / port.InputSignals[0]; // return port.OutputSignals[0] * (innerA + innerB); // }); theorems[0] = new Algebra.AutoSimplifyTransformation(_entityId, delegate(Port port) { // TODO return ManipulationPlan.DoAlter; }, delegate(Port port, SignalSet manipulatedInputs, bool hasManipulatedInputs) { if(Std.IsConstantMultiplicativeIdentity(manipulatedInputs[0])) return new SignalSet(manipulatedInputs[0]); if(Std.IsConstantMultiplicativeIdentity(manipulatedInputs[1])) return new SignalSet(manipulatedInputs[0]); if(Std.IsConstantAdditiveIdentity(manipulatedInputs[1])) return new SignalSet(IntegerValue.ConstantOne(port.Context)); if(hasManipulatedInputs) return port.Entity.InstantiatePort(port.Context, manipulatedInputs).OutputSignals; else return port.OutputSignals; }); return theorems; }
public static ITheorem[] BuildTheorems(Context context) { ITheorem[] theorems = new ITheorem[2]; theorems[0] = new Analysis.DerivativeTransformation(context.Library.LookupEntity(_entityId), delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs) { return new SignalSet(context.Builder.SubtractSimplified(manipulatedInputs)); }); theorems[1] = new Algebra.AutoSimplifyTransformation(context.Library.LookupEntity(_entityId), delegate(Port port) { // TODO return ManipulationPlan.DoAlter; }, delegate(Port port, SignalSet manipulatedInputs, bool hasManipulatedInputs) { if(SimplifySummands(manipulatedInputs) || hasManipulatedInputs) { if(manipulatedInputs.Count == 0) return new SignalSet(StdPackage.Structures.IntegerValue.ConstantAdditiveIdentity(context)); if(manipulatedInputs.Count == 1) return manipulatedInputs; return new SignalSet(context.Builder.Subtract(manipulatedInputs)); } else return port.OutputSignals; }); return theorems; }
public static ITheorem[] BuildTheorems(Context context) { ITheorem[] theorems = new ITheorem[2]; theorems[0] = new Analysis.DerivativeTransformation(_entityId, delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs) { int cnt = manipulatedInputs.Count; Signal[] addSignals = new Signal[cnt]; Signal[] multiplySignals = new Signal[cnt]; for(int i = 0; i < cnt; i++) { for(int j = 0; j < cnt; j++) multiplySignals[j] = i == j ? manipulatedInputs[j] : port.InputSignals[j]; addSignals[i] = context.Builder.MultiplySimplified(multiplySignals); } return new SignalSet(context.Builder.AddSimplified(addSignals)); }); theorems[1] = new Algebra.AutoSimplifyTransformation(_entityId, delegate(Port port) { // TODO return ManipulationPlan.DoAlter; }, delegate(Port port, SignalSet manipulatedInputs, bool hasManipulatedInputs) { if(SimplifyFactors(manipulatedInputs) || hasManipulatedInputs) { if(manipulatedInputs.Count == 0) return new SignalSet(StdPackage.Structures.IntegerValue.ConstantMultiplicativeIdentity(context)); if(manipulatedInputs.Count == 1) return manipulatedInputs; return new SignalSet(context.Builder.Multiply(manipulatedInputs)); } else return port.OutputSignals; }); return theorems; }
public static ITheorem[] BuildTheorems(Context context) { ITheorem[] theorems = new ITheorem[2]; theorems[0] = new Analysis.DerivativeTransformation(_entityId, delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs) { return new SignalSet(manipulatedInputs); }); theorems[1] = new Algebra.AutoSimplifyTransformation(_entityId, delegate(Port port) { return ManipulationPlan.DoAlter; }, delegate(Port port, SignalSet manipulatedInputs, bool hasManipulatedInputs) { return new SignalSet(manipulatedInputs); }); return theorems; }