source: http://www.seehuhn.de/pages/matrixfn
