bit::gauss
— Construction
1(const bit::matrix &A, const bit::vector &b);
gauss
gauss2(const bit::matrix &A, const bit::vector &b); gauss_for
- 1
- Instance constructor.
- 2
- Non-member factory constructor.
These construct a gauss
object for the system
On construction, a gauss
computes the reduced row echelon form of
If |
Example
#include <bit/bit.h>
int
()
main{
std::size_t m = 12;
auto A = bit::matrix<>::random(m);
auto b = bit::vector<>::random(m);
std::cout << "Solving the system A.x = b for the following A & b:\n";
(A, b);
print
// Create a solver object for the system
auto solver = bit::gauss(A, b);
// Print some general information
std::cout << "Number of equations in the system: " << solver.equation_count() << '\n';
std::cout << "Rank of the matrix A: " << solver.rank() << '\n';
std::cout << "Number of free variables: " << solver.free_count() << '\n';
std::cout << "Number of solutions to A.x = b: " << solver.solution_count() << '\n';
// Also have a look at the echelon form of A and the equivalently transformed b
std::cout << "The echelon forms of A & b are:\n";
(solver.lhs(), solver.rhs());
print}
Output (depends on the values of the random inputs)
Solving the system A.x = b for the following A & b:
011100100101 0
000111011100 1
111101000011 1
010000111110 1
110011110000 1
101100100100 1
011010110010 0
010010000111 1
101110110001 0
001100101110 1
100000011010 1
111111010100 1
Number of equations in the system: 12
Rank of the matrix A: 11
Number of free variables: 1
Number of solutions to A.x = b: 2
The echelon forms of A & b are:
100000000000 1
010000000000 0
001000000000 1
000100000000 0
000010000100 0
000001000000 0
000000100100 1
000000010000 1
000000001000 0
000000000010 1
000000000001 0
000000000000 0