I am a little bit concern about the function name ``p`` here -- ``p`` is so widely used in probabilistic context as variable names, and introducing a function called ``p`` may introduce subtle issues. Also, it is not obvious to me that ``p`` is **the** standard symbol to express matrix dimension (even though wikipedia does that).