checked docstrings and factorized matrix functions