static void LibreConvert(ref LeastSquaresFit.LSFStrings data, int fontSize) { data.IndSum = LibreMathConverter.EquationToLibre(data.IndSum, fontSize); data.IndPowerSum = LibreMathConverter.EquationToLibre(data.IndPowerSum, fontSize); data.DeSum = LibreMathConverter.EquationToLibre(data.DeSum, fontSize); data.CrossSum = LibreMathConverter.EquationToLibre(data.CrossSum, fontSize); data.UncertPowerSum = LibreMathConverter.EquationToLibre(data.UncertPowerSum, fontSize); data.SlopeEquation = LibreMathConverter.EquationToLibre(data.SlopeEquation, fontSize); data.InterceptEquation = LibreMathConverter.EquationToLibre(data.InterceptEquation, fontSize); data.YUncertEquation = LibreMathConverter.EquationToLibre(data.YUncertEquation, fontSize); data.InterceptUncertEquation = LibreMathConverter.EquationToLibre(data.InterceptUncertEquation, fontSize); data.SlopeUncertEquation = LibreMathConverter.EquationToLibre(data.SlopeUncertEquation, fontSize); }
//eventually it would be nice to hide this crap behind an interface static void LatexConvert(ref LeastSquaresFit.LSFStrings data, string fontSize) { data.IndSum = LatexConverter.ToLatex(data.IndSum, fontSize); data.IndPowerSum = LatexConverter.ToLatex(data.IndPowerSum, fontSize); data.DeSum = LatexConverter.ToLatex(data.DeSum, fontSize); data.CrossSum = LatexConverter.ToLatex(data.CrossSum, fontSize); data.UncertPowerSum = LatexConverter.ToLatex(data.UncertPowerSum, fontSize); data.SlopeEquation = LatexConverter.ToLatex(data.SlopeEquation, fontSize); data.InterceptEquation = LatexConverter.ToLatex(data.InterceptEquation, fontSize); data.YUncertEquation = LatexConverter.ToLatex(data.YUncertEquation, fontSize); data.InterceptUncertEquation = LatexConverter.ToLatex(data.InterceptUncertEquation, fontSize); data.SlopeUncertEquation = LatexConverter.ToLatex(data.SlopeUncertEquation, fontSize); }
void CalculateButClick(object sender, EventArgs e) { string str; if (IsVariableTableValid(out str)) { SetErrorText(str); LeastSquaresFit.LSFInput input; input.XValues = new List <double>(); input.YValues = new List <double>(); input.YUncertainties = new List <double>(); for (int i = 0; i < DataEntry.RowCount; i++) { input.XValues.Add(double.Parse(DataEntry[0, i].Value.ToString())); input.YValues.Add(double.Parse(DataEntry[1, i].Value.ToString())); input.YUncertainties.Add(double.Parse(DataEntry[2, i].Value.ToString())); } var results = LeastSquaresFit.Calculate(input); if (OutputFmtDrpDwn.SelectedItem.ToString() == "LibreOffice Math") { LibreConvert(ref results, int.Parse(LibreFontsizeDrpDwn.SelectedItem.ToString())); } if (OutputFmtDrpDwn.SelectedItem.ToString() == "LaTeX") { LatexConvert(ref results, LatexFontSizeDrpDwn.SelectedItem.ToString()); } textBox2.Text = results.IndSum; textBox3.Text = results.IndPowerSum; textBox5.Text = results.DeSum; textBox4.Text = results.CrossSum; textBox7.Text = results.UncertPowerSum; textBox6.Text = results.SlopeEquation; textBox9.Text = results.YUncertEquation; textBox8.Text = results.InterceptEquation; textBox11.Text = results.SlopeUncertEquation; textBox10.Text = results.InterceptUncertEquation; } else { SetErrorText(str); } }