5 ヶ月 前
コミット
f187a02c00

+ 6 - 5
06_Newton_uklady_rownan/Form1.Designer.cs

@@ -46,9 +46,10 @@
       // pictureBox1
       // 
       this.pictureBox1.Image = global::_06_Newton_uklady_rownan.Properties.Resources.nielin;
-      this.pictureBox1.Location = new System.Drawing.Point(779, 12);
+      this.pictureBox1.Location = new System.Drawing.Point(636, 15);
       this.pictureBox1.Name = "pictureBox1";
-      this.pictureBox1.Size = new System.Drawing.Size(460, 149);
+      this.pictureBox1.Size = new System.Drawing.Size(330, 101);
+      this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
       this.pictureBox1.TabIndex = 1;
       this.pictureBox1.TabStop = false;
       // 
@@ -74,9 +75,9 @@
       // button1
       // 
       this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
-      this.button1.Location = new System.Drawing.Point(518, 15);
+      this.button1.Location = new System.Drawing.Point(417, 15);
       this.button1.Name = "button1";
-      this.button1.Size = new System.Drawing.Size(255, 101);
+      this.button1.Size = new System.Drawing.Size(213, 101);
       this.button1.TabIndex = 4;
       this.button1.Text = "Rozwiąż ukł. równań";
       this.button1.UseVisualStyleBackColor = true;
@@ -86,7 +87,7 @@
       // 
       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
       this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-      this.ClientSize = new System.Drawing.Size(1251, 450);
+      this.ClientSize = new System.Drawing.Size(990, 450);
       this.Controls.Add(this.button1);
       this.Controls.Add(this.label1);
       this.Controls.Add(this.tbEps);

+ 10 - 11
06_Newton_uklady_rownan/Newton_Raphson.cs

@@ -9,11 +9,13 @@ namespace _06_Newton_uklady_rownan
   public class Newton_Raphson
   {
     public int licznik;
+    private int n;
 
     public double[] Oblicz(double eps, double[] x0, FW[] fn, FW[,] fprim)
     {
+      n = x0.Length;
       licznik = 0;
-      double[] h = null;
+      double[] h;
       double[] x = (double[])x0.Clone();
       do
       {
@@ -22,13 +24,12 @@ namespace _06_Newton_uklady_rownan
         double[,] J = liczJ(fprim, x);
         h = liczH(J, B);
         Dodaj(x, h);
-      } while (norma(h) > eps);
+      } while (Norma(h) > eps);
       return x;
     }
 
     private void Dodaj(double[] x, double[] h)
     {
-      int n = x.Length;
       for (int i = 0; i < n; i++)
         x[i] = x[i] + h[i];
     }
@@ -45,7 +46,6 @@ namespace _06_Newton_uklady_rownan
 
     private double[,] liczJ(FW[,] fprim, double[] x)
     {
-      int n = x.Length;
       double[,] J = new double[n, n];
       for (int i = 0; i < n; i++)
         for (int j = 0; j < n; j++)
@@ -55,20 +55,19 @@ namespace _06_Newton_uklady_rownan
 
     private double[] liczB(FW[] fn, double[] x)
     {
-      int n = x.Length;
       double[] B = new double[n];
       for (int i = 0; i < n; i++)
         B[i] = -fn[i](x);
       return B;
     }
 
-    private double norma(double[] h)
+    private double Norma(double[] h)
     {
-      double nor = 0;
-      foreach (double v in h)
-        nor = nor + v * v;
-      nor = Math.Sqrt(nor);
-      return nor;
+      double norma = 0;
+      for (int i = 0; i < n; i++)
+        norma = norma + h[i] * h[i];
+      norma = Math.Sqrt(norma);
+      return norma;
     }
   }
 }