check number of args to matrix functions