Library for automatic algorithms optimization via fast matrix exponentiation