Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private double CalculateMinor(int i, int j)
- {
- return CreateMatrixWithoutColumn(j)
- .CreateMatrixWithoutRow(i)
- .CalculateDeterminant();
- }
- public Matrix CreateInvertibleMatrix()
- {
- if (this.rows != this.cols)
- return null;
- var determinant = CalculateDeterminant();
- if (Math.Abs(determinant) < 0.0000001)
- return null;
- var result = new Matrix(rows, cols);
- ProcessFunctionOverData((i, j) =>
- {
- result[i, j] = ((i + j) % 2 == 1 ? -1 : 1) *
- CalculateMinor(i, j) / determinant;
- });
- result = result.Transpose();
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement