Last active
September 18, 2018 06:55
-
-
Save blubberdiblub/bb142618f18c013c3af53b869d5ae479 to your computer and use it in GitHub Desktop.
linear sweep variant #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void sweepLinear(double min, double max, int num_intervals) { | |
for (int i = 0; i <= num_intervals; i++) { | |
int j = num_intervals - i; | |
double value = (max * i + min * j) / num_intervals; | |
doSomethingWithValue(value); | |
} | |
} | |
/* Output: | |
1.5 | |
2.0 | |
2.5 | |
1.5 | |
1.6 | |
1.7 | |
1.8 | |
1.9 | |
2.0 | |
2.1 | |
2.2 | |
2.3 | |
2.4 | |
2.5 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment