Skip to content

Commit 1bfbd42

Browse files
refactor
1 parent 2f6508a commit 1bfbd42

File tree

1 file changed

+0
-9
lines changed

1 file changed

+0
-9
lines changed

linear_algebra/matrix_trace.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,21 @@
1515
def trace(matrix: NDArray[float64]) -> float:
1616
"""
1717
Calculate the trace of a square matrix.
18-
1918
The trace is the sum of the diagonal elements of a square matrix.
20-
2119
Parameters:
2220
matrix (NDArray[float64]): A square matrix
23-
2421
Returns:
2522
float: The trace of the matrix
26-
2723
Raises:
2824
ValueError: If the matrix is not square
29-
3025
Examples:
3126
>>> import numpy as np
3227
>>> matrix = np.array([[1.0, 2.0], [3.0, 4.0]], dtype=float)
3328
>>> trace(matrix)
3429
5.0
35-
3630
>>> matrix = np.array([[2.0, -1.0, 3.0], [4.0, 5.0, -2.0], [1.0, 0.0, 7.0]], dtype=float)
3731
>>> trace(matrix)
3832
14.0
39-
4033
>>> matrix = np.array([[5.0]], dtype=float)
4134
>>> trace(matrix)
4235
5.0
@@ -50,10 +43,8 @@ def trace(matrix: NDArray[float64]) -> float:
5043
def trace_properties_demo(matrix: NDArray[float64]) -> dict:
5144
"""
5245
Demonstrate various properties of the trace operation.
53-
5446
Parameters:
5547
matrix (NDArray[float64]): A square matrix
56-
5748
Returns:
5849
dict: Dictionary containing trace properties and calculations
5950
"""

0 commit comments

Comments
 (0)