public JsonResult Index(LinEq linEq) { var info = new LinEqInfo(); var parser = new LinEqParser(linEq.Expression); try { parser.Initialize(); info.IsSuccess = true; } catch (Exception e) { info.IsSuccess = false; if (e is ArgumentNullException) { info.ErrorMessage = "You have not entered the equation!"; } else { info.ErrorMessage = e.Message; } } var solver = new LinEqSolver(parser.MM, parser.Vector, parser.SystemSize); double[] vectorSol = new double[parser.SystemSize]; info.IsXForm = parser.IsXForm; if (info.IsSuccess) { try { vectorSol = solver.Solve(); info.IsSuccess = true; } catch (Exception e) { info.IsSuccess = false; info.ErrorMessage = e.Message; } } if (info.IsSuccess) { SolutionBuilder sb = new SolutionBuilder(vectorSol, info.IsXForm); info.Solution = sb.Build(); } //string pars = Parser.Parse(linEq.Expression); //Matrix m = Matrix.Parse(pars); //ViewBag.Re = pars; var json = JsonConvert.SerializeObject(info); return Json(json); }
public ActionResult test(LinEq linEq) { var info = new LinEqInfo(); var parser = new LinEqParser(linEq.Expression); try { parser.Initialize(); info.IsSuccess = true; } catch (Exception e) { info.IsSuccess = false; info.ErrorMessage = e.Message; } var solver = new LinEqSolver(parser.MM, parser.Vector, parser.SystemSize); double[] vectorSol = new double[parser.SystemSize]; if (info.IsSuccess) { try { vectorSol = solver.Solve(); info.IsSuccess = true; } catch (Exception e) { info.IsSuccess = false; info.ErrorMessage = e.Message; } } if (info.IsSuccess) { SolutionBuilder sb = new SolutionBuilder(vectorSol, info.IsXForm); info.Solution = sb.Build(); } return View(); }