Skip to content

Instantly share code, notes, and snippets.

Created May 26, 2014 20:07
Show Gist options
  • Select an option

  • Save anonymous/61f3c619ccd5beaa90d7 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/61f3c619ccd5beaa90d7 to your computer and use it in GitHub Desktop.
Smok kurwa, dragon curve
#!/bin/bash
for i in {0..3}
do
echo "zapisuje wyniki dla $((i+1)) watku"
cat wyniki.txt | grep "$i\$" > temp
sort temp > $i
done
#echo 'set terminal png font "/usr/share/fonts/dejavu/DejaVuSans.ttf" 20 size 1200,1000' > gnuplot.gnu
#echo 'set output "wykres.png"' >> gnuplot.gnu
printf 'plot ' > gnuplot.gnu
for i in {0..3}
do
printf " \"$i\" with points ps 0.5 pt 1 lt $((i+1))" >> gnuplot.gnu
if [ $i -ne "3" ]
then
printf ", " >> gnuplot.gnu
fi
done
gnuplot gnuplot.gnu
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <omp.h>
int main(int argc, char* argv[]) {
double x,y;
int a,i, threadNum;
FILE *fp;
srand(time(NULL));
if ((fp=fopen("wyniki.txt", "w")) == NULL) {
printf ("Blad fopen()!\n");
exit(1);
}
x=1;
y=1;
#pragma omp parallel for num_threads(4)
for (i=1;i<=7000;i++) {
a=(int)(rand() / (RAND_MAX + 1.0) * 2.0);
if(a==0) {
x=-0.4*x-1;
y=-0.4*y+0.01;
// x=-0.4*x-0.1;
// y=-0.4*y+0.00001;
} else {
x=0.76*x-0.4*y;
y=0.4*x+0.76*y;
// x=0.766666*x-0.4*y;
// y=0.444444*x+0.766666*y;
}
fprintf(fp,"%19.15lf\t%19.15lf\t%d\n", x, y, omp_get_thread_num() );
}
fclose(fp);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment