3 ms·
> You can implement matrix exponentiation recursively however. And tail recursively, and – going full circle – you can convert that tail recursion into iterati
by tmoertel 9y ago
> You can implement matrix exponentiation recursively however.
And tail recursively, and – going full circle – you can convert that tail recursion into iteration (see [1] for example, using techniques described in [2]).
[1] Iterative fast-power implementation in Python
https://github.com/tmoertel/practice/blob/master/libraries/tomlib.py#L143 https://github.com/tmoertel/practice/blob/master/libraries/t...
[2] Recursion to Iteration, Part 1: The Simple Method, secret features, and accumulators
http://blog.moertel.com/posts/2013-05-11-recursive-to-iterative.html http://blog.moertel.com/posts/2013-05-11-recursive-to-iterat...