Encog.MathUtil.Matrices.Decomposition.LUDecomposition.Solve C# (CSharp) Method

Solve() public method

Solve the matrix for a 1d array.
public Solve ( double value_ren ) : double[]
value_ren double The value to solve for.
return double[]
        public double[] Solve(double[] value_ren)
        {
            if (value_ren == null)
            {
                throw new MatrixError("value");
            }

            if (value_ren.Length != LU.Length)
            {
                throw new MatrixError("Invalid matrix dimensions.");
            }

            if (!IsNonsingular)
            {
                throw new MatrixError("Matrix is singular");
            }

            // Copy right hand side with pivoting
            int count = value_ren.Length;
            var b = new double[count];
            for (int i = 0; i < b.Length; i++)
            {
                b[i] = value_ren[piv[i]];
            }

            int rows = LU[0].Length;
            int columns = LU[0].Length;
            double[][] lu = LU;


            // Solve L*Y = B
            var X = new double[count];
            for (int i = 0; i < rows; i++)
            {
                X[i] = b[i];
                for (int j = 0; j < i; j++)
                {
                    X[i] -= lu[i][j]*X[j];
                }
            }

            // Solve U*X = Y;
            for (int i = rows - 1; i >= 0; i--)
            {
                // double sum = 0.0;
                for (int j = columns - 1; j > i; j--)
                {
                    X[i] -= lu[i][j]*X[j];
                }
                X[i] /= lu[i][i];
            }
            return X;
        }

Same methods

LUDecomposition::Solve ( System.Matrix B ) : System.Matrix

Usage Example

 public override void Iteration()
 {
     LUDecomposition decomposition = null;
     double num;
     double num2;
     double num3;
     double num4;
     int num5;
     int num6;
     IMLData data;
     double num7;
     double num8;
     if ((((uint) num4) | 15) != 0)
     {
         goto Label_0399;
     }
     goto Label_01C7;
     Label_0022:
     base.PostIteration();
     if ((((uint) num5) & 0) == 0)
     {
         return;
     }
     goto Label_01C7;
     Label_0044:
     this._xd7d571ecee49d1e4 = Math.Abs((double) ((this._x8557b7ee760663f3 - this._xc7c4e9c099884228) / (2.0 * num)));
     Label_0073:
     this.Error = num;
     goto Label_0022;
     Label_00F1:
     if ((num4 >= num3) && (this._x3271cefb1a159639 < 1E+25))
     {
         this._x3271cefb1a159639 *= 10.0;
         num5 = 0;
     Label_01EF:
         if (num5 < this._xe2982b936ae423cd)
         {
             this._xc410e3804222557a[num5][num5] = this._x3cb63876dda4b74a[num5] + (this._x3271cefb1a159639 + this._x6ad505c7ef981b0e);
             num5++;
             if ((((uint) num7) + ((uint) num3)) >= 0)
             {
                 goto Label_01EF;
             }
         }
         else
         {
             if ((((uint) num7) + ((uint) num8)) > uint.MaxValue)
             {
                 return;
             }
             decomposition = new LUDecomposition(this._x05fb16197e552de6);
             if (!decomposition.IsNonsingular)
             {
                 goto Label_00F1;
             }
             this._xdadd8f92d75a3aba = decomposition.Solve(this._x878c4eb3cef19a5a);
         }
         if (((uint) num6) >= 0)
         {
             if (0 != 0)
             {
                 goto Label_0340;
             }
             goto Label_01C7;
         }
         goto Label_029A;
     }
     this._x3271cefb1a159639 /= 10.0;
     if (this._x6c57e14b737e51f6 && (decomposition != null))
     {
         num8 = Trace(decomposition.Inverse());
         this._xc7c4e9c099884228 = this._xe2982b936ae423cd - (this._x6ad505c7ef981b0e * num8);
         if (((uint) num7) < 0)
         {
             goto Label_0044;
         }
         this._x6ad505c7ef981b0e = ((double) this._xe2982b936ae423cd) / ((2.0 * num2) + num8);
         if ((((uint) num4) | 0xfffffffe) != 0)
         {
             goto Label_0044;
         }
         goto Label_0022;
     }
     goto Label_0073;
     Label_0137:
     num7 = this._x61830ac74d65acc3.Ideal[0] - data[0];
     num += num7 * num7;
     num6++;
     Label_0161:
     if (num6 < this._x8557b7ee760663f3)
     {
         this._xb12276308f0fa6d9.GetRecord((long) num6, this._x61830ac74d65acc3);
         data = this._x87a7fc6a72741c2e.Compute(this._x61830ac74d65acc3.Input);
         goto Label_0137;
     }
     num /= 2.0;
     num4 = (this._xd7d571ecee49d1e4 * num) + (this._x6ad505c7ef981b0e * num2);
     goto Label_00F1;
     Label_01C7:
     num2 = this.UpdateWeights();
     num = 0.0;
     num6 = 0;
     goto Label_0161;
     Label_029A:
     if ((((uint) num7) | 0xff) == 0)
     {
         goto Label_0137;
     }
     this._x3271cefb1a159639 /= 10.0;
     goto Label_00F1;
     Label_0340:
     num4 = num3 + 1.0;
     if ((((uint) num4) - ((uint) num6)) >= 0)
     {
         goto Label_029A;
     }
     Label_0399:
     base.PreIteration();
     this._x2f33d779e5a20b28 = NetworkCODEC.NetworkToArray(this._x87a7fc6a72741c2e);
     if ((((uint) num8) | 4) == 0)
     {
         goto Label_0022;
     }
     IComputeJacobian jacobian = new JacobianChainRule(this._x87a7fc6a72741c2e, this._xb12276308f0fa6d9);
     num = jacobian.Calculate(this._x2f33d779e5a20b28);
     num2 = this.x01818299df58497e();
     this.CalculateHessian(jacobian.Jacobian, jacobian.RowErrors);
     num3 = (this._xd7d571ecee49d1e4 * num) + (this._x6ad505c7ef981b0e * num2);
     goto Label_0340;
 }
All Usage Examples Of Encog.MathUtil.Matrices.Decomposition.LUDecomposition::Solve