(Solved) : Implement Lu Decomposition Pivoting Scaling C Using Following Starter Code Use Function S Q44169370 . . .
Implement LU decomposition with pivoting and scaling in c++.Using the following starter code. Use the function signatures(method name and argument types and ordering) in the starter codebelow.
// C++ starter code
#include <cmath>
#include <vector>
#include <iostream>
void pivot(const std::vector<std::vector<double>>&a, std::vector<uint> &o, conststd::vector<double> &s, uint k) {
// …
}
bool decompose(std::vector<std::vector<double>>&a, std::vector<uint> &o, std::vector<double>&s, double tol) {
bool er = false;
uint n = a.size();
o.resize(n,0);
s.resize(n,0.0);
// …
return er;
}
std::vector<double> substitute(conststd::vector<std::vector<double>> &a, conststd::vector<uint> &o, std::vector<double> b){
uint n = b.size();
std::vector<double> x(n,0.0);
// …
return x;
}
std::vector<double>ludecomp(std::vector<std::vector<double>> a,std::vector<double> b, double tol) {
std::vector<double> s;
std::vector<uint> o;
bool err = decompose(a, o, s, tol);
std::vector<double> x;
if (!err) {
x = substitute(a,o,b);
}
return x;
}
//use to test code
int main() {
std::vector<std::vector<double>> A ={{3,-0.1,-0.2},{0.1,7,-0.3},{0.3,-0.2,10}};
std::vector<double> b = {7.85,-19.3,71.4};
double tol = 0.001;
std::vector<double> x = ludecomp(A,b,tol);
for (double xx : x) std::cout << xx << std::endl;
}
Expert Answer
Answer to Implement LU decomposition with pivoting and scaling in c++. Using the following starter code. Use the function signatur…
OR