/// <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 }; }