Add template class Matrix
Use the Matrix class instead of IntMatrix and CharMatrix