import math, strutils type Matrix[height, width: static Positive; T: SomeNumber] = array[height, array[width, T]] #################################################################################################### proc `$`(m: Matrix): string = for i, row in m: var line = "[" for j, val in row: line.addSep(" ", 1) line.add($val) line.add("]\n") result.add(line) #################################################################################################### # Templates. template elementWise(m1, m2: Matrix; op: proc(v1, v2: m1.T): auto): untyped = var result: Matrix[m1.height, m1.width, m1.T] for i in 0..