diff --git a/determinate2x2.py b/determinate2x2.py index a5fa58d..db34cfe 100644 --- a/determinate2x2.py +++ b/determinate2x2.py @@ -1,4 +1,21 @@ from typing import List +""" +Calculates the determinant of a 2x2 matrix. +Args: + llist (List[List[int]]): A 2x2 matrix represented as a list of two lists, each containing two integers. +Returns: + int: The determinant of the 2x2 matrix. +Raises: + AssertionError: If the input is not a 2x2 matrix. +Example: + >>> det2x2([[1, 2], [3, 4]]) + -2 + +NOTE: You call the module with determinate2x2.det2x2(M) where M is the 2x2 matrix. If M is not a 2x2 matrix, +you will receive an AssertionError: "Matrix is not 2x2" + +""" + def det2x2(llist: List[List[int]])->int: assert len(llist) == 2 and len(llist[0]) == 2, "Matrix is not 2x2" diff --git a/determinate3x3.py b/determinate3x3.py index 87d0bda..cfc202b 100644 --- a/determinate3x3.py +++ b/determinate3x3.py @@ -1,4 +1,17 @@ from typing import List +""" +Module for calculating the determinant of a 3x3 matrix. +Functions: + neg_odd_vals(lst: List[int]) -> List[int]: + Returns a new list where every value at an odd index is negated. + det3x3(M: List[List[int]]) -> int: + Calculates and returns the determinant of a 3x3 matrix M using Laplace expansion along the first row. + Requires an external module 'determinate2x2' with a function 'det2x2' for 2x2 determinants. + +NOTE: You call determinate3x3.det3x3(M) to find the determinate of matrix M. If M is not a 3x3 matrix, you +will receive an AssertionError: "Matrix is not 3x3" + +""" import determinate2x2 import copy