Encog.MathUtil.Matrices.Matrix.GetMatrix C# (CSharp) Method

GetMatrix() public method

Get a submatrix.
public GetMatrix ( int r, int c ) : Matrix
r int Array of row indices.
c int Array of column indices.
return Matrix
        public Matrix GetMatrix(int[] r, int[] c)
        {
            var result = new Matrix(r.Length, c.Length);
            double[][] b = result.Data;
            try
            {
                for (int i = 0; i < r.Length; i++)
                {
                    for (int j = 0; j < c.Length; j++)
                    {
                        b[i][j] = matrix[r[i]][c[j]];
                    }
                }
            }
            catch (IndexOutOfRangeException)
            {
                throw new MatrixError("Submatrix indices");
            }
            return result;
        }

Same methods

Matrix::GetMatrix ( int i0, int i1, int c ) : Matrix
Matrix::GetMatrix ( int i0, int i1, int j0, int j1 ) : Matrix

Usage Example

Exemplo n.º 1
0
 public Matrix Solve(Matrix B)
 {
     int cols;
     Matrix matrix;
     double[][] data;
     int num2;
     int num3;
     int num4;
     int num5;
     int num6;
     int num7;
     int num8;
     if (B.Rows == this.x6088325dec1baa2a)
     {
         while (!this.IsNonsingular)
         {
             throw new MatrixError("Matrix is singular.");
         }
         cols = B.Cols;
         matrix = B.GetMatrix(this.xf4c1900fcf4a6b03, 0, cols - 1);
         data = matrix.Data;
         goto Label_0237;
     }
     goto Label_0251;
     Label_0016:
     if (num7 < num5)
     {
         num8 = 0;
         goto Label_0050;
     }
     num5--;
     if ((((uint) num6) - ((uint) num6)) > uint.MaxValue)
     {
         goto Label_013D;
     }
     Label_003D:
     if (num5 >= 0)
     {
         goto Label_00CB;
     }
     return matrix;
     Label_004A:
     num8++;
     Label_0050:
     if (num8 < cols)
     {
         data[num7][num8] -= data[num5][num8] * this.x6f7a05b81c35b16c[num7][num5];
         if (0 != 0)
         {
             goto Label_00CB;
         }
         goto Label_004A;
     }
     num7++;
     goto Label_0016;
     Label_00CB:
     num6 = 0;
     Label_0097:
     if (num6 < cols)
     {
         data[num5][num6] /= this.x6f7a05b81c35b16c[num5][num5];
         if ((((uint) num6) + ((uint) num2)) <= uint.MaxValue)
         {
             if (0 == 0)
             {
                 num6++;
                 if ((((uint) num6) + ((uint) num8)) > uint.MaxValue)
                 {
                     goto Label_0237;
                 }
                 goto Label_0097;
             }
             goto Label_004A;
         }
         goto Label_01A1;
     }
     num7 = 0;
     goto Label_0016;
     Label_013D:
     if (num2 < this.x57e9faf3ffdc07cc)
     {
         num3 = num2 + 1;
         goto Label_0187;
     }
     if (((uint) num4) >= 0)
     {
         goto Label_01D4;
     }
     Label_015B:
     num4++;
     Label_0161:
     if (num4 < cols)
     {
         data[num3][num4] -= data[num2][num4] * this.x6f7a05b81c35b16c[num3][num2];
         goto Label_015B;
     }
     if ((((uint) num5) | 1) != 0)
     {
         num3++;
     }
     Label_0187:
     if (num3 >= this.x57e9faf3ffdc07cc)
     {
         num2++;
         if (2 != 0)
         {
             if ((((uint) num7) - ((uint) cols)) > uint.MaxValue)
             {
                 goto Label_0251;
             }
             goto Label_013D;
         }
         goto Label_01D4;
     }
     Label_01A1:
     num4 = 0;
     goto Label_0161;
     Label_01D4:
     if ((((uint) num8) + ((uint) num8)) <= uint.MaxValue)
     {
         num5 = this.x57e9faf3ffdc07cc - 1;
         goto Label_003D;
     }
     goto Label_00CB;
     Label_0237:
     num2 = 0;
     if ((((uint) num8) + ((uint) num6)) >= 0)
     {
         goto Label_013D;
     }
     Label_0251:
     throw new MatrixError("Matrix row dimensions must agree.");
 }