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

all:Out.txt Out.times.png

Out.times.png:out.times.txt Makefile
	echo '\
set term png ;\
set key left ;\
set xlabel "matrix size n" ;\
set ylabel "time, sec" ;\
set title \
"Givens QR-decomposition times [$(shell mcs --version)] [$(shell uname -m)]" ;\
set out "$@" ;\
N=50; s=0.1 ;\
f(x)=s+(x/N)**3 ;\
fit f(x) "$<" via s,N ;\
plot \
 "$<" with p \
,f(x) with lines title sprintf("%3.1f+(n/%3.0f)^3",s,N) \
	'|gnuplot

out.times.txt:main.exe #Makefile
	>$@
	for n in $$(seq 150 10 270); do \
		time --output $@ --format "$$n %U" --append $(MONO) $< $$n; done

Out.txt:main.exe
	$(MONO) $< > $@ 2>log

main.exe: main.cs matlib.dll
	$(MCS) $< -reference:$(lastword $^)

matlib.dll: ../matrix/matrix.cs ../matrix/vector.cs qr.cs
	$(MCS) $^ -target:library -out:$@

clean:
	rm -rf [Oo]ut* *.dll *.exe log* *log
