[genius] foo
- From: George Lebl <jirka src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [genius] foo
- Date: Wed, 21 Sep 2016 23:51:04 +0000 (UTC)
commit eda18763f7d3a6293a302961535c2f18f1080412
Author: Jiri (George) Lebl <jiri lebl gmail com>
Date: Wed Sep 21 18:48:27 2016 -0500
foo
ChangeLog | 4 ++
examples/complex-analysis-mandelbrot-set.gel | 42 ++++++++++++++++++
examples/complex-analysis-newton-fractal.gel | 61 ++++++++++++++++++++++++++
src/mpwrap.c | 7 +---
4 files changed, 108 insertions(+), 6 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a938751..b0dfeb7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,10 @@ Wed Sep 07 14:45:53 2016 Jiri (George) Lebl <jirka 5z com>
* ve/ve-misc.c: ignore a warning in ve_strftime
+Wed Sep 21 18:47:47 2016 Jiri (George) Lebl <jirka 5z com>
+
+ * src/mpwrap.c: simplify abs_sq for real numbers
+
Wed Aug 24 17:58:18 2016 Jiri (George) Lebl <jirka 5z com>
* examples/complex-analysis-mesh.gel,
diff --git a/examples/complex-analysis-mandelbrot-set.gel b/examples/complex-analysis-mandelbrot-set.gel
new file mode 100644
index 0000000..2609474
--- /dev/null
+++ b/examples/complex-analysis-mandelbrot-set.gel
@@ -0,0 +1,42 @@
+# Category: Complex Analysis
+# Name: Mandelbrot set
+#
+# Draw the Mandelbrot set
+#
+
+iterations = 10;
+
+LinePlotWindow = [-2,2,-2,2];
+
+LinePlotDrawLegends = false;
+PlotWindowPresent(); # Make sure the window is raised
+
+points = null;
+
+k=1;
+
+function DrawThePlot () = (
+ PlotCanvasFreeze ();
+ LinePlotClear ();
+ LinePlotDrawPoints (points, "color", "blue", "thickness", 3);
+ PlotCanvasThaw ();
+);
+
+for x = -2.0 to 2.0 by 0.02 do (
+ for y = -2.0 to 2.0 by 0.02 do (
+ c = z = x+1i*y;
+ for m=0 to iterations do (
+ z = z^2+c;
+ if |z| >= 2.0 then break
+ );
+ if m == iterations then (
+ points = [points;c];
+ increment k;
+ # every 100 point display intermediate picture
+ if k % 100 == 0 then
+ DrawThePlot()
+ )
+ )
+);
+
+DrawThePlot();
diff --git a/examples/complex-analysis-newton-fractal.gel b/examples/complex-analysis-newton-fractal.gel
new file mode 100644
index 0000000..d943727
--- /dev/null
+++ b/examples/complex-analysis-newton-fractal.gel
@@ -0,0 +1,61 @@
+# Category: Complex Analysis
+# Name: Newton Fractal
+#
+# Draw the basins of attraction of running the Newton algortihm
+# with different starting point for computing the third root.
+# The three roots are drawn in three different colors
+#
+
+iterations = 10;
+
+LinePlotWindow = [-2,2,-2,2];
+
+LinePlotDrawLegends = false;
+PlotWindowPresent(); # Make sure the window is raised
+
+points1 = null;
+points2 = null;
+points3 = null;
+
+k1 = 1;
+k2 = 1;
+k3 = 1;
+
+function DrawThePlot () = (
+ PlotCanvasFreeze ();
+ LinePlotClear ();
+ LinePlotDrawPoints (points1, "color", "blue", "thickness", 3);
+ LinePlotDrawPoints (points2, "color", "red", "thickness", 3);
+ LinePlotDrawPoints (points3, "color", "green", "thickness", 3);
+ PlotCanvasThaw ();
+);
+
+for x = -2.0 to 2.0 by 0.02 do (
+ for y = -2.0 to 2.0 by 0.02 do (
+ c = z = x+1i*y;
+ for m=0 to iterations do (
+ z = z-(z^3-1)/(2*z^2);
+ if |z-1| < 0.5 then (
+ points1@(k1,) = [Re(c),Im(c)];
+ increment k1;
+ break
+ ) else if |z-(-0.5+0.866025403784i)| < 0.5 then (
+ points2@(k2,) = [Re(c),Im(c)];
+ increment k2;
+ break
+ ) else if |z-(-0.5-0.866025403784i)| < 0.5 then (
+ points3@(k3,) = [Re(c),Im(c)];
+ increment k3;
+ break
+ )
+ );
+
+ # every 1000 point display intermediate picture
+ if (k1+k2+k3) % 1000 == 0 then (
+ DisplayVariables(`k1,`k2,`k3);
+ DrawThePlot()
+ )
+ )
+);
+
+DrawThePlot();
diff --git a/src/mpwrap.c b/src/mpwrap.c
index e2ac0a7..99ad6ed 100644
--- a/src/mpwrap.c
+++ b/src/mpwrap.c
@@ -3540,13 +3540,8 @@ void
mpw_abs_sq (mpw_ptr rop,mpw_ptr op)
{
if (MPW_IS_REAL (op)) {
- if(mpwl_sgn(op->r)<0)
- mpw_neg(rop,op);
- else
- mpw_set(rop,op);
-
/* have to actually square now */
- mpw_mul (rop, rop, rop);
+ mpw_mul (rop, op, op);
} else {
MpwRealNum t = {{NULL}};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]