Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Gaussian Elimination & 2d Arrays

807580Jan 16 2010 — edited Jan 16 2010
I'm working on a program that does Gaussian Elimination. The input is supposed to be a double array with the dimensions of [i+1], or [row][column]. The top loop only goes through twice and nothing changes. Any help as to what's going on will greatly help.
public double[][] solveForControlPoints(double[][] inputs){
		//step 1
		for(int i=0; i<inputs.length-1;i++){ <-- Error here @ 
			System.out.println("Loop:" + i);
			//part a
			for(int o=i; o< inputs.length-1; o++){
inputs[i][o] = inputs[i][o] / inputs[i][i];
}
//part b
for(int o=i+1; o<inputs.length-1; o++){
double mult = -inputs[o][i];
for(int x=i; x<inputs.length-1; x++){
inputs[o][x] += mult * inputs[i][x];
}
}
}
//step 2
for(int i=inputs[1].length-2; i != -1; i--){

for(int x=i; x< inputs[i].length-2; x++){
inputs[i][inputs[1].length-1] -= (inputs[i][x] * inputs[x][inputs.length-1]);
}
}
return inputs;
}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 13 2010
Added on Jan 16 2010
2 comments
112 views