--- /dev/null
+/*
+ * morpheus - defines.h
+ *
+ * default parameters and program defines
+ *
+ */
+
+#define DEFAULT_X_SEG 50
+#define DEFAULT_Y_SEG 50
+#define DEFAULT_Z_SEG 100
+
+#define DEFAULT_SLOPE_CC 1
+#define DEFAULT_START_CC 0
+
+/* program defines, dont touch ;) */
+
+#ifdef DEBUG
+ #define DEBUG 1
+#else
+ #define DEBUG 0
+#endif
+
+#define printfd(fmt,args...) if(DEBUG) printf(fmt,##args);
+
*
* refs:
* - J. K. N. Lindner. Habilationsschrift, Universitaet Augsburg.
- * - Maik Hรคberlen. Diplomarbeit, Universitaet Augsburg.
+ * - Maik Haeberlen. Diplomarbeit, Universitaet Augsburg.
*/
+#include <stdio.h>
+#include <stdlib.h>
+#include "defines.h"
+
+/* global variables */
+int sum_z_segments;
+
+int usage()
+{
+ puts("usage:");
+ puts("-h: help");
+ puts("-a <value> \t slope of C concentration with depth (default 1)");
+ puts("-c <value> \t concentration at depths 0 (default 0)");
+ puts("-x <value> \t # x segments (default 50)");
+ puts("-y <value> \t # y segments (default 50)");
+ puts("-z <value> \t # z segments (default 100)");
+ return -23;
+}
+
+int main(int argc,char **argv) {
+ int x_seg,y_seg,z_seg; /* amount of segments */
+ int x,y,z; /* segments */
+ int i; /* for counting */
+ int slope_cc,start_cc; /* C concentration: slope, c(0) */
+
+ /* default values */
+ x_seg=DEFAULT_X_SEG-1;
+ y_seg=DEFAULT_Y_SEG-1;
+ z_seg=DEFAULT_Z_SEG-1;
+ slope_cc=DEFAULT_SLOPE_CC;
+ start_cc=DEFAULT_START_CC;
+
+ /* parse command args */
+ for(i=1;i<argc;i++)
+ {
+ if(argv[i][0]=='-')
+ {
+ switch(argv[i][1])
+ {
+ case 'h':
+ usage();
+ return 23;
+ break;
+ case 'a':
+ slope_cc=atoi(argv[++i]);
+ break;
+ case 'c':
+ start_cc=atoi(argv[++i]);
+ break;
+ case 'x':
+ x_seg=atoi(argv[++i]);
+ break;
+ case 'y':
+ y_seg=atoi(argv[++i]);
+ break;
+ case 'z':
+ z_seg=atoi(argv[++i]);
+ break;
+ }
+ } else usage();
+ }
+
+ /* calculate sum_z_segments one time! */
+ sum_z_segments=0;
+ for(i=0;i<z_seg;i++) sum_z_segments+=(start_cc+i*slope_cc);
+ printfd("debug: sum z segments -> %d\n",sum_z_segments);
+
+
+ /* testing ... */
+
+ for(i=0;i<100;i++)
+ {
+ x=rand_get(x_seg);
+ y=rand_get(y_seg);
+ z=rand_get_lgp(slope_cc,start_cc);
+ printf ("x=%d y=%d z=%d\n",x,y,z);
+ }
+ return 23;
+}
--- /dev/null
+/*
+ * random.c - functions to get random values
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "defines.h"
+
+extern int sum_z_segments;
+
+/* return random integer between 0 - max */
+int rand_get(int max) {
+ return((int) (rand() * (max*1.0/RAND_MAX)) );
+}
+
+/* get z value (linear growth of probability with depths) */
+int rand_get_lgp(int slope_cc,int start_cc) {
+ int z,i;
+ z=rand_get(sum_z_segments);
+ for(i=0;;i++) {
+ z-=i*slope_cc;
+ if(z<=0) break;
+ }
+ return i;
+}
+