For this you will write a Gaussian Elimination routine (with or without pivoting - for most of you, I highly suggest without) that solves the equation A x = b where A is a square matrix (num by num), and x and b are vectors. A and b are known, you are solving for x. It will return ierr, where ierr will be a non zero value if there is a problem. You may determine what non zero number to return for what problems. Your prototypes follow:

C++:

void ge(double **A,double b[],long int num,double x[],long int ierr)

Recommended Answers

All 3 Replies

Member Avatar for iamthwee

Indeed, but we're not a homework writing service.

commented: Damn straight we aren't! +29

not asking to write the code....asking for help to understand it or start it off. I know I have to do a nested loop but I'm confused a little with the **A

commented: No, actually you didn't ask for anything at all. -4

A is a square matrix. In C++ that means A is a multidimensional array of doubles like this:

double A[x][y];

where x and y are constants and known at compile time.

Alternatively, since x and y probably won't be known at compile time, then you can use dynamic memory to reserve memory for A by declaring A like this:

double ** A;

and using the keyword new to reserve the memory needed. In this case x and y will be the same number, probably num, as A must be a square matrix. When declared like this A can be used as an array with the []s allowing you to acces rows or columns, and the [][] allowing you to access any given value within the array.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.