This project implements a modular Java program to perform various matrix operations such as:
- Addition and Subtraction
- Multiplication
- Transpose
- Rank Calculation
- Determinant
- Inverse
It follows an object-oriented approach and clean package structure for better maintainability.
Matrix/
├── src/
│ ├── driver/ # Contains the main class to drive the program
│ │ └── MatrixDriver.java
│ ├── matrix/ # Contains Matrix class and MatrixOperations interface
│ │ ├── Matrix.java
│ │ └── MatrixOperations.java
│ ├── operation/ # Contains operation-specific implementations
│ │ ├── Add_Sub.java
│ │ ├── Matrix_Mul.java
│ │ ├── Transpose.java
│ │ ├── Rank.java
│ │ ├── Determinant.java
│ │ └── Inverse.java
│ └── exceptions/ # Contains custom exceptions
│ └── NotSquareMatrixException.java
├── out/ # Compiled .class files (created after build)
└── runMatrixProject.bat # Script to compile and run the project
- All operations implement the
MatrixOperationsinterface. - The
Matrixclass handles input, validation, and common matrix utilities. - Each operation class (like
Add_Sub,Inverse, etc.) contains logic specific to that operation. MatrixDriveris the main class that takes user input and dispatches the selected operation.
Simply run:
runMatrixProject.batThis script:
- Compiles all Java files from
src/ - Stores compiled
.classfiles inout/ - Runs the
MatrixDriverclass fromout/
cd src
javac -d ../out matrix/**/*.java operation/*.java exceptions/*.java driver/*.java
java -cp ../out driver.MatrixDriver- Clean, modular codebase
- Follows best OOP practices
- Handles square matrix validation via custom exception
- Uses Java 17+ features (like enhanced
switch)
- Java JDK 17 or above
- Any terminal or IDE (VS Code, IntelliJ, etc.)
- Support for file input/output
- GUI using JavaFX or Swing
- More matrix operations (e.g., eigenvalues, LU decomposition)
Akshat Srivastava
Feel free to contribute or fork the project!