This Python program allows you to perform various matrix operations using the numpy
library. It takes user input for two matrices and performs operations like addition, multiplication, subtraction, division, transposition, and trace calculation. The program runs interactively in a loop, allowing the user to choose different operations until they decide to exit.
- Matrix Addition: Adds two matrices element-wise.
- Matrix Multiplication: Multiplies two matrices (if dimensions are compatible).
- Matrix Subtraction: Subtracts one matrix from another element-wise.
- Matrix Division: Divides two matrices element-wise.
- Matrix Transpose: Transposes each of the input matrices.
- Matrix Trace: Calculates the trace (sum of the diagonal elements) for each matrix.
- Python 3.x
numpy
library
You can install the required library with:
pip install numpy