matrix should be a const reference parameter.
Following the convention used elsewhere, out parameters are first, in parameters are last.