[xiph-commits] r12048 - trunk/sushivision

giles at svn.xiph.org giles at svn.xiph.org
Mon Nov 6 15:30:25 PST 2006


Author: giles
Date: 2006-11-06 15:30:24 -0800 (Mon, 06 Nov 2006)
New Revision: 12048

Added:
   trunk/sushivision/example_fractal.c
Log:
Add Mandel/Julia set (z->z^2+c) objective as a demo.


Added: trunk/sushivision/example_fractal.c
===================================================================
--- trunk/sushivision/example_fractal.c	2006-11-06 22:53:53 UTC (rev 12047)
+++ trunk/sushivision/example_fractal.c	2006-11-06 23:30:24 UTC (rev 12048)
@@ -0,0 +1,88 @@
+/*
+ *
+ *     sushivision copyright (C) 2006 Monty <monty at xiph.org>
+ *
+ *  sushivision is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2, or (at your option)
+ *  any later version.
+ *   
+ *  sushivision is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *   
+ *  You should have received a copy of the GNU General Public License
+ *  along with sushivision; see the file COPYING.  If not, write to the
+ *  Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * 
+ */
+
+#include <stdio.h>
+#include <math.h>
+#include "sushivision.h"
+
+sushiv_instance_t *s;
+#define MAX_ITER 1024
+
+static double fractal_objective(double *d){
+  int i;
+  double z, zi, zz;
+  const double c=d[0],ci=d[1];
+
+  z = d[2]; zi = d[3];
+  for(i=0;i<MAX_ITER;i++){
+    zz = z*z - zi*zi + c;
+    zi = 2.0*z*zi + ci;
+    z  = zz;
+    if (z*z + zi*zi > 4.0) return (double)i/MAX_ITER;
+  }
+
+  return 0.0;
+}
+
+static int time_callback(sushiv_dimension_t *d){
+
+
+  return 1; // indicate that default processing chain should continue
+}
+
+static int blocksize_callback(sushiv_dimension_t *d){
+
+
+  return 1; // indicate that default processing chain should continue
+}
+
+int sushiv_submain(int argc, char *argv[]){
+
+  s=sushiv_new_instance();
+
+  sushiv_new_dimension(s,0,"Re(c)",
+		       5,(double []){-3,-1.5,0,1.5,3},
+		       time_callback,
+		       SUSHIV_X_RANGE|SUSHIV_Y_RANGE);
+  sushiv_new_dimension(s,1,"Im(c)",
+		       5,(double []){-3,-1.5,0,1.5,3},
+		       time_callback,
+		       SUSHIV_X_RANGE|SUSHIV_Y_RANGE);
+
+  sushiv_new_dimension(s,2,"Re(z0)",
+		       5,(double []){-3,-1.5,0,1.5,3},
+		       NULL,
+		       SUSHIV_X_RANGE|SUSHIV_Y_RANGE);
+  sushiv_new_dimension(s,3,"Im(z0)",
+		       5,(double []){-3,-1.5,0,1.5,3},
+		       NULL,
+		       SUSHIV_X_RANGE|SUSHIV_Y_RANGE);
+  
+  sushiv_new_objective(s,0,"fractal",fractal_objective,0);
+
+  sushiv_new_panel_2d(s,0,"Mandel/Julia Fractal",2,
+		      (double []){0,1.0},
+		      (int []){0,-1},
+		      (int []){0,1,2,3,-1},
+		      0);
+  
+  return 0;
+}



More information about the commits mailing list