A function that calculates the LQR "optimal" (see reference) state feedback matrix for discrete state space systems. The method is based on the iterative solution of the Riccati equation. Some examples are provided and results have been compared with the corresponding Matlab function. Any comments will be welcome.