division method

List division(
  1. List list1,
  2. List list2
)

Matrix element from first matrix is divided by elements from second element.Both list1 and list2 must have same shape and element in list2 must not be zero; otherwise ouput matrix contain infinity.

var div = m2d.division([[1,1],[1,1]],[[2,0],[2,2]]);
print(div);
// [[0.5, Infinity], [0.5, 0.5]]

Implementation

List division(List list1, List list2) {
  var list1Shape = shape(list1);
  var list2Shape = shape(list2);
  if (list1Shape.toString() != list2Shape.toString()) {
    throw new Exception(
        'operands could not be broadcast together with shapes $list1Shape $list2Shape');
  }
  var result = utldivition(list1, list2);
  return result;
}