[llvm-commits] CVS: llvm-test/SingleSource/Benchmarks/Misc-C++/mandel-text.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sat Sep 24 21:40:01 PDT 2005
Changes in directory llvm-test/SingleSource/Benchmarks/Misc-C++:
mandel-text.cpp added (r1.1)
---
Log message:
new testcase to generate an ascii-art mandlebrot
---
Diffs of the changes: (+61 -0)
mandel-text.cpp | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 61 insertions(+)
Index: llvm-test/SingleSource/Benchmarks/Misc-C++/mandel-text.cpp
diff -c /dev/null llvm-test/SingleSource/Benchmarks/Misc-C++/mandel-text.cpp:1.1
*** /dev/null Sat Sep 24 23:40:00 2005
--- llvm-test/SingleSource/Benchmarks/Misc-C++/mandel-text.cpp Sat Sep 24 23:39:49 2005
***************
*** 0 ****
--- 1,61 ----
+ #include <stdio.h>
+ int main()
+ {
+ // output size
+ int rows = 40, cols = 78;
+
+ // number of iterations before we quit
+ int maxiter = 255;
+
+ int slowdown = 2000;
+
+ // size and position of the rect on the imaginary plane
+ double fViewRectReal = -2.3, fViewRectImg = -1.0;
+ double fMagLevel = 0.05;
+
+ for (int y=0; y < rows; y++)
+ {
+ // imaginary component of "c"
+ double fCImg = fViewRectImg + y * fMagLevel;
+
+ for (int x=0; x < cols; x++)
+ {
+ // real component of "c"
+ bool bInside;
+ int n;
+
+ for (int SLOW = 0; SLOW < slowdown; ++SLOW) {
+ double fCReal = fViewRectReal + x * fMagLevel;
+ double fZReal = fCReal;
+ double fZImg = fCImg;
+ bInside = true;
+
+ // apply the formula...
+ for (n=0; n < maxiter; n++) {
+ double fZRealSquared = fZReal * fZReal;
+ double fZImgSquared = fZImg * fZImg;
+
+ // have we escaped?
+ if (fZRealSquared + fZImgSquared > 4) {
+ bInside = false;
+ break;
+ }
+
+ // z = z^2 + c
+ fZImg = 2 * fZReal * fZImg + fCImg;
+ fZReal = fZRealSquared - fZImgSquared + fCReal;
+ }
+ }
+
+ if (bInside)
+ putchar(' ');
+ else if (n > 4)
+ putchar('.');
+ else if (n > 2)
+ putchar('+');
+ else
+ putchar('*');
+ }
+ putchar('\n');
+ }
+ }
More information about the llvm-commits
mailing list