public static DerivationFormatter newDerivationFormatter(string name, Derivator derinet) { global::System.IntPtr cPtr = morphodita_csharpPINVOKE.DerivationFormatter_newDerivationFormatter(name, Derivator.getCPtr(derinet)); DerivationFormatter ret = (cPtr == global::System.IntPtr.Zero) ? null : new DerivationFormatter(cPtr, true); return(ret); }
public virtual Derivator getDerivator() { global::System.IntPtr cPtr = morphodita_csharpPINVOKE.Morpho_getDerivator(swigCPtr); Derivator ret = (cPtr == global::System.IntPtr.Zero) ? null : new Derivator(cPtr, false); return(ret); }
public void ReplaceWithIndex(string wba, string waa, string word) { Assert.Equal("ZZZtttt", Derivator.Replace(wba, waa, word, 0)); Assert.Equal("tZZZttt", Derivator.Replace(wba, waa, word, 1)); Assert.Equal("ttZZZtt", Derivator.Replace(wba, waa, word, 2)); Assert.Equal("tttZZZt", Derivator.Replace(wba, waa, word, 3)); Assert.Equal("ttttZZZ", Derivator.Replace(wba, waa, word, 4)); }
public void TestConstantDydx() { Parser p = new Parser("10"); Node n = p.Parse(); n = Derivator.dydx(n); if (n.Payload != "0") { Assert.Fail(); } }
public void TestMultiplicationDydx() { Parser p = new Parser("2x"); Node n = p.Parse(); Node dydx = Derivator.dydx(n); Node realdydx = (new Parser("(0*x)+(1*2)")).Parse(); if (!Node.IsEqual(dydx, realdydx)) { Assert.Fail(); } }
public void Derive(string[] ba, string[] aa, string InitialWord, int[] steps, string[] variables, string expectedResult) { Derivator derivator = new Derivator(new Derivation(ba, aa, steps, variables, InitialWord)); string result = derivator.Derive(); Assert.Equal(expectedResult, result); var generatedSteps = derivator.GetStepsByWord(expectedResult).ToArray(); Derivator derivator2 = new Derivator(new Derivation(ba, aa, generatedSteps, variables, InitialWord)); Assert.Equal(expectedResult, derivator2.Derive()); }
static void Main(string[] args) { Tokenizer t = new Tokenizer(); Parser p = new Parser(); Solver s = new Solver(); Derivator d = new Derivator(); Simplifier simp = new Simplifier(); //ha he's a simp Console.Write("Solve equation (S/I/D):"); string decision = Console.ReadLine(); while (true) { Console.Write("Equation:"); List <Node> nodes = t.Tokenize(Console.ReadLine()); foreach (Node n in nodes) { Console.WriteLine(n.t + " " + n.op + " " + n.value + " " + n.var + " " + n.f + " " + n.priority_value + "\n"); } Console.WriteLine("\n"); Console.WriteLine("\n"); Console.WriteLine("\n"); Console.WriteLine("\n"); Node nf = p.Parse(nodes); PrintTree(nf, "", true); Console.WriteLine("\n"); Console.WriteLine("\n"); Console.WriteLine("\n"); Console.Write(OrganizeTree(nf, nf)); Console.WriteLine("\n"); Console.WriteLine("\n"); Console.WriteLine("\n"); if (decision == "S" || decision == "S") { Console.WriteLine(s.Solve(nf)); } else if (decision == "I" || decision == "i") { Node origin_simp = simp.Simplify(nf); PrintTree(origin_simp, "", true); Console.WriteLine(OrganizeTree(origin_simp, origin_simp)); } else if (decision == "D" || decision == "d") { nf.f = Flags.Derivate; Node derivated = d.Derivate(nf); PrintTree(derivated, "", true); Console.WriteLine(OrganizeTree(derivated, derivated)); } } }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Derivator obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
public void Replace(string wba, string waa, string word, string expectedResult) { Assert.Equal(expectedResult, Derivator.Replace(wba, waa, word)); }