Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public partial class Form1 : Form
- {
- Newton newton;
- GradientReduction grad;
- LeastSquares sqr;
- CoordinateDescent desc;
- public Form1()
- {
- InitializeComponent();
- newton = new Newton();
- grad = new GradientReduction();
- sqr = new LeastSquares();
- desc = new CoordinateDescent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- while (graphView.Series.Count > 0)
- {
- graphView.Series.RemoveAt(0);
- }
- tableView.Text = newton.print();
- }
- private void tableButton_CheckedChanged(object sender, EventArgs e)
- {
- if (tableButton.Checked)
- {
- graphView.Visible = false;
- tableView.Visible = true;
- }
- }
- private void graphButton_CheckedChanged(object sender, EventArgs e)
- {
- if (graphButton.Checked)
- {
- graphView.Visible = true;
- tableView.Visible = false;
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- while (graphView.Series.Count > 0)
- {
- graphView.Series.RemoveAt(0);
- }
- List<LinkedList<double>> Xi = grad.solve();
- graphView.Series.Add("X1");
- graphView.Series.Add("X2");
- graphView.Series.Add("X3");
- for (int i = 0; i < Xi.Count; i++)
- {
- graphView.Series[i].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
- double[] X = new double[Xi[i].Count];
- Xi[i].CopyTo(X, 0);
- for (int j = 0; j < X.Length; j++)
- graphView.Series[i].Points.AddXY(j + 1, X[j]);
- }
- tableView.Text = grad.print();
- }
- private void button4_Click(object sender, EventArgs e)
- {
- sqr.solve();
- double[] X = sqr.getX();
- double[] Y = sqr.getY();
- double[] Yapp = sqr.getAppY();
- while (graphView.Series.Count > 0)
- {
- graphView.Series.RemoveAt(0);
- }
- graphView.Series.Add("Y appr.");
- graphView.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
- graphView.Series.Add("Y precise");
- graphView.Series[1].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
- for (int i = 0; i < X.Length; i++)
- {
- graphView.Series[0].Points.AddXY(X[i], Yapp[i]);
- }
- for (int i = 0; i < X.Length; i++)
- {
- graphView.Series[1].Points.AddXY(X[i], Y[i]);
- }
- tableView.Text = sqr.print();
- }
- private void button3_Click(object sender, EventArgs e)
- {
- desc.solve();
- while (graphView.Series.Count > 0)
- {
- graphView.Series.RemoveAt(0);
- }
- List<List<double>> Xi = desc.getXi();
- graphView.Series.Add("X1");
- graphView.Series.Add("X2");
- graphView.Series.Add("X3");
- for (int i = 0; i <3; i++)
- {
- graphView.Series[i].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
- for (int j = 0; j < Xi.Count; j++)
- graphView.Series[i].Points.AddXY(j + 1, Xi[j][i]);
- }
- tableView.Text = desc.print();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement