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) { Builder b = context.Builder; Signal[] outputs = new Signal[manipulatedInputs.Count]; ReadOnlySignalSet cotangents = Std.Cotangent(context, port.InputSignals); for(int i = 0; i < outputs.Length; i++) outputs[i] = b.MultiplySimplified(port.OutputSignals[i], cotangents[i], manipulatedInputs[i]); return b.Negate(outputs); }); theorems[1] = new BasicTransformation(_entityId.DerivePostfix("TrigonometricSubstitute"), new MathIdentifier("TrigonometricSubstitute", "Std"), delegate() { return new Pattern(new EntityCondition(_entityId)); }, delegate(Port port) { return ManipulationPlan.DoAlter; }, delegate(Port port, SignalSet transformedInputs, bool hasTransformedInputs) { return port.Context.Builder.Invert(Std.Sine(port.Context, transformedInputs)); //Signal[] ret = new Signal[transformedInputs.Count]; //for(int i = 0; i < ret.Length; i++) // ret[i] = port.Context.Builder.Invert(Std.Sine(port.Context, transformedInputs[i])); //return ret; }); return theorems; }
public static ReadOnlySignalSet Cosine(Context context, IList<Signal> op) { if(context == null) throw new ArgumentNullException("context"); return context.Builder.Functions(new MathIdentifier("Cosine", "Std"), op); }
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) { Builder b = context.Builder; ReadOnlySignalSet squares = b.Square(port.OutputSignals); Signal one = IntegerValue.ConstantOne(context); SignalSet outputs = new SignalSet(); for(int i = 0; i < manipulatedInputs.Count; i++) outputs.Add((one + squares[i]) * manipulatedInputs[i]); return outputs; }); theorems[1] = new BasicTransformation(_entityId.DerivePostfix("TrigonometricSubstitute"), new MathIdentifier("TrigonometricSubstitute", "Std"), delegate() { return new Pattern(new EntityCondition(_entityId)); }, delegate(Port port) { return ManipulationPlan.DoAlter; }, delegate(Port port, SignalSet transformedInputs, bool hasTransformedInputs) { Signal[] ret = new Signal[transformedInputs.Count]; for(int i = 0; i < ret.Length; i++) ret[i] = Std.Sine(port.Context, transformedInputs[i]) / Std.Cosine(port.Context, transformedInputs[i]); return ret; }); 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) { Builder b = context.Builder; Signal[] outputs = new Signal[manipulatedInputs.Count]; ReadOnlySignalSet squares = b.Square(port.OutputSignals); Signal one = IntegerValue.ConstantOne(context); for(int i = 0; i < outputs.Length; i++) outputs[i] = (one + squares[i]) * manipulatedInputs[i]; return b.Negate(outputs); }); theorems[1] = new BasicTransformation("CotangentTrigonometricSusbtitute", "Std", "TrigonometricSubstitute", "Std", delegate(Port port) { return port.Entity.EntityId.Equals("Cotangent", "Std"); }, delegate(Port port) { return ManipulationPlan.DoAlter; }, delegate(Port port, SignalSet transformedInputs, bool hasTransformedInputs) { Signal[] ret = new Signal[transformedInputs.Count]; for(int i = 0; i < ret.Length; i++) ret[i] = Std.Cosine(port.Context, transformedInputs[i]) / Std.Sine(port.Context, transformedInputs[i]); return ret; }); 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 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(context.Library.LookupEntity(_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 Scheduler(Context context) { _context = context; _eventSignals = new List<SignalEventItem>(128); _deltaEvents = new Stack<SignalEventItem>(128); _timeQueue = new EventTimeline(); }
public static Signal Cotangent(Context context, Signal op) { if(context == null) throw new ArgumentNullException("context"); return context.Builder.Function(new MathIdentifier("Cotangent", "Std"), op); }
public Project(Context context) { _context = context; _context.Library.LoadPackageManager(new MathNet.Symbolics.StdPackage.StdPackageManager(context)); _namedSystems = new Dictionary<Guid, MathSystem>(); _localObservers = new List<ISystemObserver>(); _parser = new Parser(); MathSystem sys = AddSystem(); LoadSystem(sys.InstanceId); }
public ParserScanner(TextReader reader, MathSystem system) { if(system == null) throw new ArgumentNullException("system"); if(reader == null) throw new ArgumentNullException("reader"); tokenizer = new ParserMarker(reader, system.Context); this.system = system; this.context = system.Context; }
public static ITheorem[] BuildTheorems(Context context) { ITheorem[] theorems = new ITheorem[0]; //theorems[0] = new Analysis.DerivativeTransformation("HyperbolicCotangentDerivative", "Std", context.Library.LookupEntity("HyperbolicCotangent", "Std"), // delegate(Port port, Signal[] derivedInputSignals) // { // }); return theorems; }
public static ITheorem[] BuildTheorems(Context context) { ITheorem[] theorems = new ITheorem[1]; theorems[0] = new Analysis.DerivativeTransformation(context.Library.LookupEntity(_entityId), delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs) { return context.Builder.Negate(manipulatedInputs); }); return theorems; }
public LexerScanner(TextReader reader, Context context) { this.lexer = new LexerMarker(reader); this.context = context; this.executorCharacter = context.ExecutorCharacter; this.seperatorCharacter = context.SeparatorCharacter; this.listEncapsulation = context.ListEncapsulation; this.vectorEncapsulation = context.VectorEncapsulation; this.setEncapsulation = context.SetEncapsulation; this.scalarEncapsulation = context.ScalarEncapsulation; this.literalEncapsulation = context.LiteralEncapsulation; }
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 - 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(_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[1]; theorems[0] = new Analysis.DerivativeTransformation(context.Library.LookupEntity(_entityId), delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs) { Builder b = context.Builder; SignalSet outputs = new SignalSet(); for(int i = 0; i < manipulatedInputs.Count; i++) outputs.Add(manipulatedInputs[i] / port.InputSignals[i]); return outputs; }); return theorems; }
public static ITheorem[] BuildTheorems(Context context) { ITheorem[] theorems = new ITheorem[1]; theorems[0] = new Analysis.DerivativeTransformation(_entityId, delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs) { Builder b = context.Builder; SignalSet outputs = new SignalSet(); for(int i = 0; i < manipulatedInputs.Count; i++) outputs.Add(b.Negate(b.DivideSimplified(manipulatedInputs[i], b.Square(port.InputSignals[i])))); return outputs; }); return theorems; }
public static ITheorem[] BuildTheorems(Context context) { ITheorem[] theorems = new ITheorem[1]; theorems[0] = new Analysis.DerivativeTransformation(_entityId, delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs) { Builder b = context.Builder; SignalSet outputs = new SignalSet(); ReadOnlySignalSet cosines = Std.Cosine(context, port.InputSignals); for(int i = 0; i < manipulatedInputs.Count; i++) outputs.Add(cosines[i] * manipulatedInputs[i]); return outputs; }); return theorems; }
public static ITheorem[] BuildTheorems(Context context) { ITheorem[] theorems = new ITheorem[1]; theorems[0] = new Analysis.DerivativeTransformation(_entityId, delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs) { Builder b = context.Builder; Signal two = IntegerValue.ConstantTwo(context); SignalSet outputs = new SignalSet(); for(int i = 0; i < manipulatedInputs.Count; i++) outputs.Add(b.MultiplySimplified(two, port.InputSignals[i], manipulatedInputs[i])); return outputs; }); return theorems; }
public static ITheorem[] BuildTheorems(Context context) { ITheorem[] theorems = new ITheorem[1]; theorems[0] = new Analysis.DerivativeTransformation(context.Library.LookupEntity(_entityId), delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs) { Builder b = context.Builder; Signal[] outputs = new Signal[manipulatedInputs.Count]; ReadOnlySignalSet sines = Std.Sine(context, port.InputSignals); for(int i = 0; i < outputs.Length; i++) outputs[i] = sines[i] * manipulatedInputs[i]; return b.Negate(outputs); }); return theorems; }
public LexerScanner(TextReader reader, Context context) { if(context == null) throw new ArgumentNullException("context"); if(reader == null) throw new ArgumentNullException("reader"); this.lexer = new LexerMarker(reader); this.context = context; this.executorCharacter = context.ExecutorCharacter; this.seperatorCharacter = context.SeparatorCharacter; this.listEncapsulation = context.ListEncapsulation; this.vectorEncapsulation = context.VectorEncapsulation; this.setEncapsulation = context.SetEncapsulation; this.scalarEncapsulation = context.ScalarEncapsulation; this.literalEncapsulation = context.LiteralEncapsulation; }
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; }
/// <summary> /// Separates factors in a product that depend on x from those that do not. /// </summary> /// <returns> /// A signal array [a,b], where a is the product of the factors not /// depending on x, and b the product of those depending on x. /// </returns> /// <remarks><see cref="product"/> is assumed to be automatic simplified</remarks> public static Signal[] SeparateFactors(Context context, Signal product, Signal x) { SignalSet freePart = new SignalSet(); SignalSet dependentPart = new SignalSet(); if(product.IsDrivenByPortEntity("Multiply", "Std")) { ReadOnlySignalSet factors = product.DrivenByPort.InputSignals; foreach(Signal s in factors) { if(s.DependsOn(x)) dependentPart.Add(s); else freePart.Add(s); } } else if(product.DependsOn(x)) dependentPart.Add(product); else freePart.Add(product); Signal freeSignal = context.Builder.MultiplySimplified(freePart); Signal dependentSignal = context.Builder.MultiplySimplified(dependentPart); return new Signal[] { freeSignal, dependentSignal }; }
private static PositiveIntegerSetProperty InnerDeserialize(Context context, XmlReader reader) { return Instance; }
/// <summary>Clear the buffer. Replace the current stream with a new one.</summary> public void Reset(TextReader reader, MathSystem system) { if(system == null) throw new ArgumentNullException("system"); if(reader == null) throw new ArgumentNullException("reader"); this.system = system; this.context = system.Context; tokenizer.Reset(reader, context); }
public ParserScanner(TextReader reader, MathSystem system) { tokenizer = new ParserMarker(reader, system.Context); this.system = system; this.context = system.Context; }
protected static ComplexValueCategory InnerDeserialize(Context context, XmlReader reader) { return Instance; }
private static RealSetProperty InnerDeserialize(Context context, XmlReader reader) { return Instance; }
private static ConstantSignalProperty InnerDeserialize(Context context, XmlReader reader) { return Instance; }
/// <summary>Clear the buffer. Replace the current stream with a new one.</summary> public void Reset(TextReader reader, MathSystem system) { this.system = system; this.context = system.Context; tokenizer.Reset(reader, context); }
protected static AlgebraicExpressionCategory InnerDeserialize(Context context, XmlReader reader) { return Instance; }