Question: 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)

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 code below.

// C++ starter code #include #include #include

void pivot(const std::vector> &a, std::vector &o, const std::vector &s, uint k) { // ... }

bool decompose(std::vector> &a, std::vector &o, std::vector &s, double tol) { bool er = false; uint n = a.size(); o.resize(n,0); s.resize(n,0.0); // ... return er; }

std::vector substitute(const std::vector> &a, const std::vector &o, std::vector b) { uint n = b.size(); std::vector x(n,0.0); // ... return x; }

std::vector ludecomp(std::vector> a, std::vector b, double tol) { std::vector s; std::vector o; bool err = decompose(a, o, s, tol); std::vector x; if (!err) { x = substitute(a,o,b); } return x; }

//use to test code

int main() { std::vector> A = {{3,-0.1,-0.2},{0.1,7,-0.3},{0.3,-0.2,10}}; std::vector b = {7.85,-19.3,71.4}; double tol = 0.001; std::vector x = ludecomp(A,b,tol); for (double xx : x) std::cout << xx << std::endl; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!