MatrixCPP is a simple C++11 project for performing basic matrix operations such as addition, subtraction, and multiplication.
- C++11 or later
- Git (optional, for cloning the repository)
- Clone the repository:
git clone https://github.com/yourusername/matrixcpp.git cd matrixcpp
- Create a build directory:
mkdir build cd build
- Run CMake to configure the project and build it to static library:
cmake .. cmake --build .
#include "matrixcpp.hpp"
#include <iostream>
int main() {
try {
Matrix<int> m1({{1, 2}, {3, 4}});
Matrix<int> m2({{5, 6}, {7, 8}});
Matrix<int> result = m1 + m2;
for (const auto& row : result.content) {
for (int value : row) {
std::cout << value << " ";
}
std::cout << std::endl;
}
} catch (const std::invalid_argument& e) {
std::cerr << "Error: " << e.what() << std::endl;
}
return 0;
}