Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Matrix LU(double eps = 1E-16)
- {
- if (!this.IsSquare())
- {
- throw new MException("Cant work with matrix that is not square");
- }
- int n = this.Cols;
- for (int i = 0; i < n - 1; i++)
- {
- for (int j = i + 1; j < n; j++)
- {
- if (Math.Abs((double)this[i, i]) < eps)
- {
- throw new MException("Division with 0!");
- }
- matrix[j, i] = (double)matrix[j, i] / matrix[i, i];
- for (int k = i + 1; k < n; k++)
- {
- matrix[j, k] -= (double)matrix[j, i] * matrix[i, k];
- }
- }
- }
- return this;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement