Advertisement
pVinc

caputa_kod

Oct 20th, 2021
680
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.26 KB | None | 0 0
  1.             N = 3;
  2.             numericUpDown1.Value = N;
  3.             UstawTablice();
  4.             int blad;
  5.             AZ = new Complex[N + 1, N + 1];
  6.             BZ = new Complex[N + 1];
  7.             XZ = new Complex[N + 1];
  8.  
  9.             Complex E1 = 10, E2 = 10;
  10.             double R = 10, L = 10;
  11.             double C = 20;
  12.  
  13.             AZ[1, 1] = 1;
  14.             AZ[1, 2] = -1;
  15.             AZ[1, 3] = -1;
  16.             AZ[2, 1] = 0;
  17.             AZ[2, 2] = R;
  18.             AZ[2, 3] = 0;
  19.             AZ[3, 1] = 0;
  20.             AZ[3, 2] = -R;
  21.             AZ[3, 3] = new Complex(0, L - C);
  22.  
  23.             BZ[1] = Complex.Zero;
  24.             BZ[2] = E1;
  25.             BZ[3] = E2;
  26.  
  27.             for (int i = 1; i <= N; i++)
  28.             {
  29.                 for (int j = 1; j <= N; j++)
  30.                 {
  31.                     MacierzA.Rows[i-1].Cells[j-1].Value = AZ[i,j].ToString();
  32.                 }
  33.                 WektorB.Rows[i - 1].Cells[0].Value = BZ[i].ToString();
  34.             }
  35.             if (radioButton1.Checked)
  36.             {
  37.                 blad = MetodaGaussa.RozRowMacGaussa(AZ, BZ, XZ, 1e-30);
  38.             }
  39.             else
  40.             {
  41.                 blad = MetodaRozkladuLU.RozRowMacCroutDoolitta(AZ, BZ, XZ, 1e-30);
  42.             }
  43.             if (blad == 0)
  44.                 for (int i = 1; i <= N; i++)
  45.                     WektorX[0, i - 1].Value = XZ[i].ToString("0.000000");
  46.  
  47.            
  48.             textBox1.Text = "IpK bilans: " + (XZ[1] - XZ[2] - XZ[3]).ToString();
  49.             textBox2.Text = "IIpK bilans: " + (E1 - XZ[2]*R).ToString();
  50.  
  51.             double Pz = (E1*XZ[1].Conjugate + E2*XZ[3].Conjugate).Re;
  52.             textBox3.Text = "  Pz = " + Pz.ToString();
  53.  
  54.            
  55.             double Podb = (XZ[2] * XZ[2].Conjugate * R).Re + (XZ[3] * XZ[3].Conjugate * (Complex.j * L - Complex.j * C)).Re;
  56.             textBox4.Text = "Podb = " + Podb.ToString();
  57.            
  58.             Complex Sz = new Complex(0, 0);
  59.             Sz = E1 * XZ[1].Conjugate + E2 * XZ[3].Conjugate;
  60.             textBox5.Text = "  Sz= " + Sz.ToString();
  61.  
  62.             Complex Sodb = new Complex(0, 0);
  63.             Sodb = (XZ[2] * XZ[2].Conjugate * R) + (XZ[3] * XZ[3].Conjugate * (Complex.j * L - Complex.j * C));
  64.             textBox6.Text = "Sodb = " + Sodb.ToString();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement