add byrow option to matrix