I want to write an algorithm in LaTeX. It's not any programming language, it is pseudocode with a very mathematical style. Furthermore it is divided in a main function and some subfunctions. I also would like to be able to comment (almost) every line to describe what it is used for.
As an example, you may want to take a look at this link: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.83.3496&rep=rep1&type=pdf
See page 10 for the code. I would like to write it in the very same style if this is somehow possible.
Any help is appreciated :)