[Template] linear recurrence with constant coefficients

Problem Description

Seeking to meet a $ K $ order homogeneous linear recursive series of $ a_i $ $ $ n-items, namely: $ a_n = \ sum_ {i = 1} ^ k f_i \ times a_ {ni} $.

analysis

First written in matrix fast power

$$\left( \begin{bmatrix} f_1 &f_2 &f_3 &f_4 & \cdots &f_{k-2} &f_{k-1} \\ 1 &0 &0 &0 & \cdots &0 &0 \\ 0 &1 &0 &0 & \cdots &0 &0\\ \cdots & \cdots& \cdots & \cdots & \cdots & \cdots & \cdots\\ 0 &0 &0 &0 & \cdots &1 &0 \end{bmatrix} \right) ^n \times \begin{bmatrix} a_{k-1} \\ a_{k-2} \\ \cdots \\ a_{1} \\ a_{0}\end{bmatrix} =\begin{bmatrix} a_{n+k-1} \\ a_{n+k-2} \\ \cdots \\ a_{n+1} \\ a_{n}\end{bmatrix}$$

So we just need to figure $ M ^ N \ times A $, then take the last number can be.

Fast power using a matrix, the complexity of $ O (k ^ 3 \ log_2n) $.

Carlay-Hamilton Theorem

Provided $ k $ eigenvalues ​​of the matrix $ A $ characteristic polynomial $ f (\ lambda) = \ prod_ {i = 1} ^ k (\ lambda_i - x) $, there is $ f (A) = 0 $, $ 0 $ zero matrix.

 

Guess you like

Origin www.cnblogs.com/lfri/p/11236711.html