public virtual Matrix Solve(Matrix B) { if (B.Rows != this.m) { throw new ArgumentException("Matrix row dimensions must agree."); } if (!this.FullRank) { throw new SystemException("Matrix is rank deficient."); } int columns = B.Columns; double[][] array = B.ToJaggedArray(); for (int i = 0; i < this.n; i++) { for (int k = 0; k < columns; k++) { double num4 = 0.0; for (int m = i; m < this.m; m++) { num4 += this.QR[m][i] * array[m][k]; } num4 = -num4 / this.QR[i][i]; for (int n = i; n < this.m; n++) { array[n][k] += num4 * this.QR[n][i]; } } } for (int j = this.n - 1; j >= 0; j--) { for (int num8 = 0; num8 < columns; num8++) { array[j][num8] /= this.Rdiag[j]; } for (int num9 = 0; num9 < j; num9++) { for (int num10 = 0; num10 < columns; num10++) { array[num9][num10] -= array[j][num10] * this.QR[num9][j]; } } } B.FromJaggedArray(array); return B[0, this.n, 0, columns]; }