From ebf363d9a43db664d1cd2eea2d531111c1571097 Mon Sep 17 00:00:00 2001 From: stormofice <58337328+stormofice@users.noreply.github.com> Date: Wed, 1 Dec 2021 01:46:34 +0100 Subject: [PATCH 1/4] Output 10000 points instead of 1000 in C implementation --- contents/IFS/code/c/IFS.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contents/IFS/code/c/IFS.c b/contents/IFS/code/c/IFS.c index 99c4826be..75f85bc35 100644 --- a/contents/IFS/code/c/IFS.c +++ b/contents/IFS/code/c/IFS.c @@ -30,15 +30,15 @@ void chaos_game(struct point *in, size_t in_n, struct point *out, int main() { struct point shape_points [3] = {{0.0,0.0}, {0.5,sqrt(0.75)}, {1.0,0.0}}; - struct point out_points[1000]; + struct point out_points[10000]; srand(time(NULL)); - chaos_game(shape_points, 3, out_points, 1000); + chaos_game(shape_points, 3, out_points, 10000); FILE *fp = fopen("sierpinksi.dat", "w+"); - for (int i = 0; i < 1000; ++i) { + for (int i = 0; i < 10000; ++i) { fprintf(fp, "%f\t%f\n", out_points[i].x, out_points[i].y); } From 2f0f3fa4d3762e41fb8637329b161d66fdc831bb Mon Sep 17 00:00:00 2001 From: stormofice <58337328+stormofice@users.noreply.github.com> Date: Wed, 1 Dec 2021 01:47:12 +0100 Subject: [PATCH 2/4] Change output file from "out.dat" to "sierpinski.dat" in lisp --- contents/IFS/code/clisp/ifs.lisp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contents/IFS/code/clisp/ifs.lisp b/contents/IFS/code/clisp/ifs.lisp index 4354ab54b..c9fc0e432 100644 --- a/contents/IFS/code/clisp/ifs.lisp +++ b/contents/IFS/code/clisp/ifs.lisp @@ -21,7 +21,7 @@ `((0 0) (0.5 ,(sqrt 0.75)) (1 0)))) ;; output the data to the "out.dat" file -(with-open-file (out "out.dat" :direction :output :if-exists :supersede) +(with-open-file (out "sierpinski.dat" :direction :output :if-exists :supersede) (flet ((format-point (p) ;; this is not very clean, but it's the simplest way to insert a tab into a string. (format nil "~f~c~f" (point-x p) #\tab (point-y p)))) From b2c49d57e09013b6ae2d8eb89758c82fea68fd12 Mon Sep 17 00:00:00 2001 From: stormofice <58337328+stormofice@users.noreply.github.com> Date: Wed, 1 Dec 2021 01:48:02 +0100 Subject: [PATCH 3/4] Change output file from "out.dat" to "sierpinski.dat" in Haskell --- contents/IFS/code/haskell/IFS.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contents/IFS/code/haskell/IFS.hs b/contents/IFS/code/haskell/IFS.hs index 9e8f4ef70..41d8b4c9a 100644 --- a/contents/IFS/code/haskell/IFS.hs +++ b/contents/IFS/code/haskell/IFS.hs @@ -27,4 +27,4 @@ main = do points = chaosGame g 10000 sierpinski showPoint (Point x y) = show x ++ "\t" ++ show y - writeFile "out.dat" $ intercalate "\n" $ map showPoint points + writeFile "sierpinski.dat" $ intercalate "\n" $ map showPoint points From 2aeac9c85cfea2ebce430870ec2d14d1ef52d00d Mon Sep 17 00:00:00 2001 From: stormofice <58337328+stormofice@users.noreply.github.com> Date: Wed, 1 Dec 2021 18:40:40 +0100 Subject: [PATCH 4/4] Introduce constant for the amount of points to generate --- contents/IFS/code/c/IFS.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/contents/IFS/code/c/IFS.c b/contents/IFS/code/c/IFS.c index 75f85bc35..e4aab3b50 100644 --- a/contents/IFS/code/c/IFS.c +++ b/contents/IFS/code/c/IFS.c @@ -29,16 +29,18 @@ void chaos_game(struct point *in, size_t in_n, struct point *out, } int main() { + const int point_count = 10000; + struct point shape_points [3] = {{0.0,0.0}, {0.5,sqrt(0.75)}, {1.0,0.0}}; - struct point out_points[10000]; + struct point out_points[point_count]; srand(time(NULL)); - chaos_game(shape_points, 3, out_points, 10000); + chaos_game(shape_points, 3, out_points, point_count); FILE *fp = fopen("sierpinksi.dat", "w+"); - for (int i = 0; i < 10000; ++i) { + for (int i = 0; i < point_count; ++i) { fprintf(fp, "%f\t%f\n", out_points[i].x, out_points[i].y); } @@ -46,4 +48,3 @@ int main() { return 0; } -