MCPcopy Create free account
hub / github.com/algorithm-archivists/algorithm-archive / chaos_game

Function chaos_game

contents/IFS/code/c/IFS.c:18–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16}
17
18void chaos_game(struct point *in, size_t in_n, struct point *out,
19 size_t out_n) {
20
21 struct point cur_point = {drand(), drand()};
22
23 for (size_t i = 0; i < out_n; ++i) {
24 out[i] = cur_point;
25 struct point tmp = random_element(in, in_n);
26 cur_point.x = 0.5 * (cur_point.x + tmp.x);
27 cur_point.y = 0.5 * (cur_point.y + tmp.y);
28 }
29}
30
31int main() {
32 const size_t point_count = 10000;

Callers 1

mainFunction · 0.70

Calls 2

random_elementFunction · 0.85
drandFunction · 0.70

Tested by

no test coverage detected