Linear Equations Solver  1.0
Using Gaussian elimination
Loading...
Searching...
No Matches
utils.h File Reference

Utility functions for matrix initialization and display. More...

#include <vector>
#include <string>
#include <chrono>
+ Include dependency graph for utils.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool InitMatrix (std::vector< std::vector< double > > &m, const std::string &filename, int &rows, int &cols)
 Initializes the matrix by reading from a .in file.
 
void ShowEquations (const std::vector< std::vector< double > > &m, int rows, int cols)
 Displays the system of linear equations.
 
bool CheckConsistency (const std::vector< std::vector< double > > &m, int rows, int cols)
 Checks the consistency of the system of equations.
 
void DisplaySolution (const std::vector< double > &solution)
 Displays the unique solution.
 
std::chrono::steady_clock::time_point StartTimer ()
 
void StopTimer (const std::chrono::steady_clock::time_point &start)
 

Detailed Description

Utility functions for matrix initialization and display.

Author
Gilbert Young
Date
2024/09/25

Definition in file utils.h.

Function Documentation

◆ CheckConsistency()

bool CheckConsistency ( const std::vector< std::vector< double > > & m,
int rows,
int cols )

Checks the consistency of the system of equations.

Parameters
mThe matrix representing the system.
rowsNumber of rows in the matrix.
colsNumber of columns in the matrix.
Returns
true If the system is consistent.
false If the system is inconsistent.

◆ DisplaySolution()

void DisplaySolution ( const std::vector< double > & solution)

Displays the unique solution.

Parameters
solutionThe solution vector.

◆ InitMatrix()

bool InitMatrix ( std::vector< std::vector< double > > & m,
const std::string & filename,
int & rows,
int & cols )

Initializes the matrix by reading from a .in file.

Parameters
mReference to the matrix to be initialized.
filenameName of the input file.
rowsReference to store the number of rows.
colsReference to store the number of columns.
Returns
true If the matrix was successfully initialized.
false If there was an error during initialization.

◆ ShowEquations()

void ShowEquations ( const std::vector< std::vector< double > > & m,
int rows,
int cols )

Displays the system of linear equations.

Parameters
mThe matrix representing the system.
rowsNumber of equations.
colsNumber of variables plus one (for constants).

◆ StartTimer()

std::chrono::steady_clock::time_point StartTimer ( )

Definition at line 157 of file utils.cpp.

158{
159 return chrono::steady_clock::now();
160}

◆ StopTimer()

void StopTimer ( const std::chrono::steady_clock::time_point & start)