The short version (well not that short) using sed with basic-regular-expressions could look something like:
sed -i 's/double arg1\[M\]\[N\],[ ]double arg2\[M\]\[N\]/const vector<vector<double>>\& arg1, const vector<vector<double>>\& arg2/' yourfiles
Example Use/Output
$ echo "void Method1(double arg1[M][N], double arg2[M][N], ...)" |
sed 's/double arg1\[M\]\[N\],[ ]double arg2\[M\]\[N\]/const vector<vector<double>>\& arg1, const vector<vector<double>>\& arg2/'
void Method1(const vector<vector<double>>& arg1, const vector<vector<double>>& arg2, ...)
You can add the additional guard of 0,/double arg1\[M\]\[N\],[ ]double arg2\[M\]\[N\]/ before the s/.../.../ to ensure only the 1st occurrence in the file is replaced if you need to limit to 1 replacement.
Edit to Add Capture Groups and Backreferences
Per your comment, if the array names need to be generalized, you can match and capture the name with \([^[]*\) and reinsert the name using a numbered backreference (\1 and \2), e.g.
sed 's/double \([^[]*\)\[M\]\[N\],[ ]double \([^[]*\)\[M\]\[N\]/const vector<vector<double>>\& \1, const vector<vector<double>>\& \2/'
Edit Per-Request for awk Solution
As mentioned in the comment, this problem does not really lend itself to an awk solution for two reasons (1) the function declaration isn't a delimited set of fields that are easily broken on a field-separator; and (2) awk does not provide for in-place replacement within a file. (some versions do, otherwise you have to use write to a new file and replace the old)
To use awk for this problem, you basically have to systematically apply the string-manipulation functions to substitute the needed substrings. Doable, just not what you would consider a normal first-choice approach. You can do it similar to:
# match line with "... arg1[M][N], double arg2[M][N]"
awk -F", " '/[^[]*\[M\]\[N\],[ ][^[]*\[M\]\[N\]/ {
gsub(/double/,"const vector<vector<double>>&") # sub double/<vector<vector<double>>&
gsub(/\[M\]\[N\]/,"") # remove [M][N]
}1' files # print record
The command above simply substitutes double for the reference to vector of vector of doubles syntax using gsub to operate on the entire record. Then uses gsub again to remove the "[M][N]" leaving the record in the form desired. There are many ways to do this is just the first second way that came to mind with awk.
sed 's/double \(arg[0-9]\)\[M\]\[N\]/const vector<vector<double>>\& \1/g'