23 throw std::runtime_error(
24 "Error in GaussianEliminationAlg: Cannot construct with negative step or max.");
57 const std::vector<float>& meanVector,
58 const std::vector<float>& sigmaVector,
59 const std::vector<float>& heightVector)
62 if (meanVector.size() != sigmaVector.size() || meanVector.size() != heightVector.size())
63 throw std::runtime_error(
"Error in GaussianEliminationAlg: Vector sizes not equal.");
72 const std::vector<float>& sigmaVector,
73 const std::vector<float>& heightVector)
76 fMatrix.resize(meanVector.size());
77 for (
size_t i = 0; i < meanVector.size(); i++) {
79 fMatrix[i].resize(meanVector.size() + 1);
80 for (
size_t j = 0; j < meanVector.size(); j++) {
81 if (sigmaVector[j] < std::numeric_limits<float>::epsilon()) {
90 fMatrix[i][meanVector.size()] = heightVector[i];
99 for (
size_t i = 0; i <
fMatrix.size(); i++) {
101 for (
size_t j = i + 1; j < (
fMatrix[i].size() - 1); j++) {
103 for (
size_t k = i; k <
fMatrix[i].size(); k++)
109 for (
int i =
fMatrix.size() - 1; i >= 0; i--) {
112 for (
size_t j = i + 1; j <
fMatrix.size(); j++)
121 std::cout <<
"GaussianEliminationAlg." << std::endl;
129 std::cout <<
"\tAugmented matrix " << std::endl;
130 for (
size_t i = 0; i <
fMatrix.size(); i++) {
131 std::cout <<
"\t\t | ";
132 for (
size_t j = 0; j <
fMatrix[i].size() - 1; j++)
133 std::cout <<
fMatrix[i][j] <<
" ";
134 std::cout <<
" | " <<
fMatrix[i][
fMatrix[i].size() - 1] <<
" |" << std::endl;
137 std::cout <<
"\tSolutions" << std::endl;
138 for (
size_t i = 0; i <
fSolutions.size(); i++)
139 std::cout <<
"\t\t" << i <<
" " <<
fSolutions[i] << std::endl;
double GetDistance(float) const
void FillDistanceLookupTable()
constexpr auto abs(T v)
Returns the absolute value of the argument.
void GaussianElimination()
void FillAugmentedMatrix(const std::vector< float > &meanVector, const std::vector< float > &sigmaVector, const std::vector< float > &heightVector)
std::vector< std::vector< double > > fMatrix
const std::vector< float > & SolveEquations(const std::vector< float > &meanVector, const std::vector< float > &sigmaVector, const std::vector< float > &heightVector)
std::vector< double > fDistanceLookupTable
GaussianEliminationAlg(float, float)
std::vector< float > fSolutions