chached matrix functions written