tasks for today:
1. Scalar Multiplication of a Matrix
2. Calculate Eigenvalues of a Matrix
------------------------------------------------
1. Scalar Multiplication of a Matrix
def scalar_multiply(matrix: list[list[int|float]], scalar: int|float) -> list[list[int|float]]:# with library functionsimport numpy as npresult = scalar * np.array(matrix)# manuallyresult = [[scalar * i for i in row] for row in matrix]return result
2. Calculate Eigenvalues of a Matrix
def calculate_eigenvalues(matrix: list[list[float|int]]) -> list[float]:# with library functionsimport numpy as npeigenvalues, vec = np.linalg.eig(np.array(matrix))# without library functions, for a 2*2 matrix# calcualte the trace and the determinant and solve the equationsreturn eigenvalues.tolist()