- #1
Saladsamurai
- 3,020
- 7
I am writing a Tridiagonal solver using c++. I know that they exist already, but I want to go through the motions for the sake of learning. I am a novice C++ user, however, even before I start writing the program, I get the feeling that the manner in which I am going to write it is not the best way. This is how I was about to start my function, but I want some input on alternative ways to do this.
As you can see, this function returns nothing; it modifies the value of the solution vector in the main() program by replacing its contents with the contents of the formal parameter soln[]. I feel like this isn't the best way. Should I instead try to return the solution vector to the main program?
What are your thoughts?
Code:
void triSolve(double oUp[],double oLow[], double oMain[],
double oRHS[], int n, double soln[])
{
// Thomas' Algorithm starts here
return;
}
where:
oUp[] = upper diagonal of tridiagonal system
oLow[] = lower diagonal of tridiagonal system
oMain[] = Main diagonal of tridiagonal system
n = size of system
oRHS[] = right hand side of tridiagonal system
soln[] = solution to the problem
oUp[] = upper diagonal of tridiagonal system
oLow[] = lower diagonal of tridiagonal system
oMain[] = Main diagonal of tridiagonal system
n = size of system
oRHS[] = right hand side of tridiagonal system
soln[] = solution to the problem
As you can see, this function returns nothing; it modifies the value of the solution vector in the main() program by replacing its contents with the contents of the formal parameter soln[]. I feel like this isn't the best way. Should I instead try to return the solution vector to the main program?
What are your thoughts?