Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unction Determinant(Matrix : TMatrix) : Integer;
- var
- Size: Integer;
- Minor: TMatrix;
- i, j, k: Integer;
- Sign: Integer;
- begin
- Size := Length(Matrix);
- if Size = 1 then
- Result := Matrix[0, 0]
- else
- begin
- Result := 0;
- Sign := 1;
- for k := 0 to Size - 1 do
- begin
- SetLength(Minor, Size - 1, Size - 1);
- for i := 1 to Size - 1 do
- for j := 0 to Size - 1 do
- begin
- if j < k then
- Minor[i - 1, j] := Matrix[i, j]
- else if j > k then
- Minor[i - 1, j - 1] := Matrix[i, j];
- end;
- Result := Result + Sign * Matrix[0, k] * Determinant(Minor);
- Sign := -Sign;
- end;
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement