replace matrix operation