Implements vector and matrix with templates.