#!/usr/athena/bin/perl use strict; sub make_binary; # ($rmin, $rmax, $rdensity, $xdensity, $xdepth, $equation) if ($#ARGV != 5) { die "$0 \$rmin \$rmax \$rdensity \$xdensity \$xdepth \$equation\n"; } my $rmin = shift; my $rmax = shift; my $rdensity = shift; my $xdensity = shift; my $xdepth = shift; my $equation = shift; print (STDERR "Creating and compiling...\n"); make_binary ($rmin, $rmax, $rdensity, $xdensity, $xdepth, $equation); print (STDERR "Executing...\n"); system ("./__bifurcation"); print (STDERR "Deleting...\n"); unlink ("__bifurcation"); print (STDERR "Done!\n"); exit; sub make_binary { my $rmin = shift; my $rmax = shift; my $rdensity = shift; my $xdensity = shift; my $xdepth = shift; my $mapping = shift; my $xmin = 0; my $xmax = 1; my $kstep = 1; my $rstep = ($rmax - $rmin) / $rdensity; my $ccodestr = " #include #include #include double drand48 (void); int main (void) { register unsigned i; register unsigned j; register unsigned k; register unsigned int ok; double x; double r; double data[$xdensity]; k = 0; for (r = $rmin; r <= $rmax; r += $rstep) { for (i = 0; i < $xdensity; i++) { x = (($xmax - $xmin) * drand48 ()) + $xmin; for (j = 0; j < $xdepth; j++) x = ($mapping); data[i] = x; } for (i = 0; i < $xdensity; i++) printf (\"%f\\t%f\\n\", r, data[i]); "; # $ccodestr .= " # ok = k; # k = (int) ((((r - $rmin) / $rstep) / $rdensity) * 100.0) + 1; # if (((k - ok) > 0) && ((k % $kstep) == 0)) # fprintf (stderr, \"%d%%\\n\", k); # "; $ccodestr .= " } return 0; } "; open (CCODE, '>', "__bifurcation.c") or die "Can't open __bifurcation.c: $!"; print (CCODE $ccodestr) or die "Can't write to __bifurcation.c: $!"; close (CCODE) or die "Can't close __bifurcation.c: $!"; system ("gcc -O3 -ansi -pedantic -Wall -lm -o __bifurcation __bifurcation.c"); unlink ("__bifurcation.c"); return; }