new TemplateMatrix class