Matrix and graph library in c++23.
The library provides a Matrix class that supports matrices of arbitrary size and type.
General Operations:
- Matrix addition and multiplication
- Transpose formation
- Rank calculation
- Solving systems of linear equations
Operations for Square Matrices:
- Inverse calculation
- Matrix exponentiation using the repeated squaring method
- Determinant calculation (using Bareiss or Gaussian elimination)
- Trace calculation
The Graph class is implemented using an adjacency matrix representation. It supports weighted, directed, and undirected graphs.
Implemented Algorithms:
- Breadth-First Search
- Depth-First Search
- Dijkstra's algorithm for finding the shortest path
- Topological sort for directed acyclic graphs
- Eulerian circuit, acyclicity, symmetry, and connectivity checks
The project implements several fundamental data structures with similar behaviour to the STL containers:
- Matrix
- Graph
- Fraction
- Vector
- Pair
- Queue
- Stackvector: A hybrid vector that utilizes stack memory for small sizes before allocating on the heap.
mkdir build && cd build && cmake ..
make
./qvmlbrThe project includes a suite of tests using the gtest framework. To build and run the tests:
mkdir _build && cd _build && cmake ..
make
./test/qvmlbr_testsThe library supports reading matrices from text files. The format is as follows:
- Matrix elements in a row are separated by spaces.
- Rows are separated by newlines.
- Each row in a matrix must have the same number of elements.
- Multiple matrices in a single file must be separated by at least one empty line.
An example of a valid input file containing two matrices:
1 2 3
4 5 6
10 20
30 40
This project, including its source code and documentation, is licensed under the GPL-3.0 license.