Matrix Transformation
Write a Python function that transforms a given matrix A using the operation
Example:
Input:
A = [[1, 2], [3, 4]], T = [[2, 0], [0, 2]], S = [[1, 1], [0, 1]]
Output:
[[0.5,1.5],[1.5,3.5]]
Reasoning:
The matrices T and S are used to transform matrix A by computing
Code:
import numpy as np
def transform_matrix(A, T, S):
A = np.array(A)
T = np.array(T)
S = np.array(S)
if np.linalg.det(T) and np.linalg.det(S):
return np.linalg.matrix_power(T, -1) @ A @ S
return -1