using GenDanDoZad;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _04_2_Gauss
{
  public partial class Form1 : Form
  {
    Log log;
    Gauss gauss = new Gauss();

    public Form1()
    {
      InitializeComponent();
      log = new Log(textBox1);
      textBox1.BackColor = Color.Black;
      textBox1.ForeColor = Color.Yellow;
      log.SetFontSize(20);
    }

    private void button1_Click(object sender, EventArgs e)
    {
      gauss.A = new double[,] {
          { 4,  1,  1,  6,  1 },
          { 3, 10,  6,  9,  8 },
          { 5,  8,  7,  6,  2 },
          { 7,  6,  0,  5,  8 },
          { 5,  7,  5,  3, 10 }
      };

      gauss.b = new double[] { 62, 216, 146, 154, 187 };

      gauss.PostProste();
      log.l("A:", gauss.A);
      log.l("b:", gauss.b, true);
      double[] x = gauss.PostOdwrotne();
      log.l("x:", x, true);
    }

    private void button2_Click(object sender, EventArgs e)
    {
      gauss.A = new double[,] {
          { 4,  1,  1,  6,  1 },
          { 3, 10,  6,  9,  8 },
          { 5,  8,  7,  6,  2 },
          { 7,  6,  0,  5,  8 },
          { 5,  7,  5,  3, 10 }
      };

      gauss.b = new double[] { 62, 216, 146, 154, 187 };

      double[] x = gauss.Oblicz();

      log.l("x:", x);

    }

    private void button3_Click(object sender, EventArgs e)
    {
      gauss.A = new double[,] {
          {  3,  0,  1,  0,  1 },
          {  0,  0,  0, -5,  4 },
          { -4,  0,  4, -2, -5 },
          { -2,  0,  4,  0,  5 },
          { -5,  1, -4,  3,  3 }
      };
      gauss.b = new double[] { -8, 19, 29, 25, 6 };
      gauss.Wybor = MetodaWyboru.Czesciowy;
      double[] x = gauss.Oblicz();
      log.l("x:", x);
    }

    private void button4_Click(object sender, EventArgs e)
    {
      gauss.A = new double[,] {
          {  3,  0,  1,  0,  1 },
          {  0,  0,  0, -5,  4 },
          { -4,  0,  4, -2, -5 },
          { -2,  0,  4,  0,  5 },
          { -5,  1, -4,  3,  3 }
      };
      gauss.b = new double[] { -8, 19, 29, 25, 6 };
      gauss.Wybor = MetodaWyboru.Pelny;
      double[] x = gauss.Oblicz();
      log.l("x:", x);
    }
  }
}
