coded matrix functions