A C/Assembly hybrid matrix calculator program supporting basic operations like Addition, Subtraction, Multiplication, Determinant, and Transpose.
Before running the program, ensure you have the following installed:
- GNU Compiler Collection (GCC)
gcc -v
- Make (GNU Make)
(Note: On Linux,
make -v
makeis usually pre-installed. On Windows, you can use MinGW or MSYS2)
The project comes with a Makefile that supports both Linux and Windows automatically.
- To compile the program:
make
- To run the program:
make run
- To clean up compiled files:
make clean
- To run tests:
make test
When you run the program (make run), you will be presented with interactive menus. You can navigate these menus using your Arrow Keys (Up/Down) and press Enter to make a selection.
You can choose to input your matrices via the console manually or read them from a file.
If you select console, the program will ask you step-by-step:
- How many matrices you want to input.
- For each matrix, its dimensions (rows and columns).
- The elements of the matrix row by row.
If you select file, the program will automatically read from a file named input.txt located in the root directory of the project.
How to format input.txt:
The format must strictly follow:
- The total number of matrices (e.g., 2).
- For each matrix:
- The number of rows and columns separated by a space (e.g.,
2 2). - The values of the matrix (can be separated by spaces or newlines).
- The number of rows and columns separated by a space (e.g.,
Example input.txt (Two 2x2 matrices):
2
2 2
1.0 2.0
3.0 4.0
2 2
5.0 6.0
7.0 8.0
After providing the matrices, you will be prompted to select an operation to perform:
- Addition (Requires 2 matrices of the same dimensions)
- Subtraction (Requires 2 matrices of the same dimensions)
- Multiplication (Requires matrices with compatible dimensions)
- Determinant (Requires a square matrix)
- Transpose (Requires 1 matrix)
- Inverse (Coming soon...)
- Exit
Finally, choose how you want to see the result:
- Console: Prints the resulting matrix or determinant value directly to your screen.
- File: Saves the result to a file named
output.txtin the root directory.
Note: If output.txt already exists, it will be overwritten.