plot.svg: out.data.txt Makefile
	echo "\
	set term svg size 800,600 font 'Times,18' fsize 18;\
	set out '$@';\
	set key bottom;\
	set tics out;\
	set xlabel 'x';\
	set ylabel 'y';\
	set title 'Linear/quadratic/cubic splines of some random data';\
	plot \
	  '$<' index 0 with points pointtype 7 title 'data'\
	, '$<' index 1 using 1:2 with lines title 'linear'\
	, '$<' index 1 using 1:3 with lines title 'quadratic'\
	, '$<' index 1 using 1:4 with lines title 'cubic'\
	, '$<' index 0 smooth csplines lw 4 dashtype (10,10) title 'gnuplot cubic spline'\
	"|tee log.gpi |gnuplot
	sed --in-place --expression 's/;/;\n/g;s/, /,\n/g' log.gpi

out.data.txt: main.py linterp.py cspline.py qspline.py
	python3 $< > $@

clean:
	rm -rf out* plot* log* __pycache__

test:
	echo $(RM)
