MONO = mono
MCS = mcs -optimize+ #-platform:arm

all:out.txt plot.times.svg
	cat $<

out.txt:main.exe
	mono $< > $@

plot.times.svg: out.times.txt Makefile
	echo '\
	set term svg;\
	set out "$@";\
	set key left;\
	set title "matrix multiplication times (`$(MCS) --version` `uname -m`)";\
	set xlabel "matrix size n";\
	set ylabel "multiplication time t, sec";\
	f(x)=b+(x/a)**c;\
	b=0.7; a=20; c=3;\
	fit f(x) "$<" via b,a;\
	plot \
	 "$<" title "measurement" \
	,f(x) title sprintf("fit: (n/%.f)^{%.2f}+%.2f",a,c,b) \
	'| gnuplot


out.times.txt: times.exe Makefile
	cat /dev/null > $@
	for n in `seq 193 10 293`; do \time -ao $@ -f "$$n %U" $(MONO) $< $$n; done

times.exe: times.cs matrix.dll
	$(MCS) $< -target:exe -reference:matrix.dll

main.exe: main.cs matrix.dll
	$(MCS) $< -target:exe -reference:matrix.dll

matrix.dll: matrix.cs vector.cs jacobi.cs cholesky.cs eigen.cs xtensions.cs
	$(MCS) $^ -target:library

clean:
	$(RM) *.exe *.dll out.*

eigen.exe:eigen.cs matrix.dll
