I Have 2 matrices (lower and upper) from the LU decomposition method, and I am trying to get the variables. Here are my Lower matrix and Upper matrix
public void getZ() {
for(int i = 0; i < z.length; i++) { // iteration
if(i != nodeApplied) { // first we initialize the z with 0
// unless we reach the node that the force was applied
z[i] = 0;
} else {
z[i] = force;
}
}
}
public void getNewZ() {
// lower
int[] newZ = new int[n]; // we create a new int list to save the values of the variables
for (int i = 0; i < n; i++) {
int decrement = 0; // all positions in the row before the diagonal subtracted
for (int j = 0; j < n; j++) {
if (j == i) { // if it is a diagonal
newZ[i] = (z[i] - decrement) / lu.lower[i][i];
} else { // if is not in the diagonal
decrement += lu.lower[i][j] * newZ[j];
}
}
}
this.z = newZ;
}
public void getVariables() {
getNewZ();
for(int i = 0; i < n; i++) {
System.out.println(z[i]);
}
}
Exception in thread "main" java.lang.NullPointerException
at Matrix.getNewZ(Matrix.java:92)
at Matrix.<init>(Matrix.java:68)
at Matrix.main(Matrix.java:118)