File tree 1 file changed +9
-2
lines changed
linear-algebra/determinant-computation
1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -10,11 +10,18 @@ def get_matrix():
10
10
print (f'Enter the elements of the matrix { rows } x{ cols } ' )
11
11
matrix = []
12
12
for i in range (rows ):
13
- row = list (map (float , input (f'Row { i + 1 } (separate element with space): ' ))) .split ()
13
+ row = list (map (float , input (f'Row { i + 1 } (separate element with space): ' ).split ()) )
14
14
if len (row ) != cols :
15
15
raise ValueError ('Number of elements does not match the number of columns!' )
16
16
matrix .append (row )
17
17
18
18
return np .array (matrix )
19
19
20
- matrix = get_matrix ()
20
+ matrix = get_matrix ()
21
+
22
+ try :
23
+ determinant = np .linalg .det (matrix )
24
+ print (f'Matrix: { matrix } ' )
25
+ print (f'Determinant of the matrix: { determinant } ' )
26
+ except ValueError as e :
27
+ print (f'An error occurred { e } ' )
You can’t perform that action at this time.
0 commit comments