Edited rdpeng's example to add matrix function solve.