public void nextIteration() {
    	double[][] nextX = new double[N][3];
    	for (int i = 0; i < N; i++) {
    		for (int k = 0; k < 3; k++)
    			nextX[i][k] = b[i][k];
    		for (int n = 0; n < 4; n++) {
    			if (R[i][n] >= 0) {
    				int index = R[i][n];
    				for (int k = 0; k < 3; k++)
    					nextX[i][k] += X[index][k];
    			}
    		}
    		for (int k = 0; k < 3; k++)
    			nextX[i][k] /= (double)D[i];
    	}
    	for (int i = 0; i < N; i++)
    		X[i] = nextX[i];
    }