Improve template recognition

The gdb printing code does not work so well for me, since the template arguments to a matrix are strings of the form "-1" and not "-0x0...1". Matching the template string against the regular expression fixes everything up nicely.