Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. private double CalculateMinor(int i, int j)
  2. {
  3. return CreateMatrixWithoutColumn(j)
  4. .CreateMatrixWithoutRow(i)
  5. .CalculateDeterminant();
  6. }
  7.  
  8. public Matrix CreateInvertibleMatrix()
  9. {
  10. if (this.rows != this.cols)
  11. return null;
  12. var determinant = CalculateDeterminant();
  13. if (Math.Abs(determinant) < 0.0000001)
  14. return null;
  15.  
  16. var result = new Matrix(rows, cols);
  17. ProcessFunctionOverData((i, j) =>
  18. {
  19. result[i, j] = ((i + j) % 2 == 1 ? -1 : 1) *
  20. CalculateMinor(i, j) / determinant;
  21. });
  22.  
  23. result = result.Transpose();
  24. return result;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement