added a type check to matrix.map, and slightly improved documentation