Cosmetics
Avoid possible overflows due to multiplication of ints
Prefix header guards with module name
Extract Matrix class to a common header
Remove unnecessary catch of bad_alloc