improve performance of functions passed to kwant
Current implementation creates matrices on every function call. Caching matrices could improve performance. However current implementation looks like giving correct results so improvement can be postponed.