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:


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

9 Years
Discussion Span
Last Post by Lerner

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

Votes + Comments
No, actually you didn't ask for anything at all.

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.