matrix functions completed v1