algorithm13 = function algorithm13(a, b, callback) {
    // a arrays
    var adata = a._data;
    var asize = a._size;
    var adt = a._datatype; // b arrays

    var bdata = b._data;
    var bsize = b._size;
    var bdt = b._datatype; // c arrays

    var csize = []; // validate dimensions

    if (asize.length !== bsize.length) {
      throw new DimensionError(asize.length, bsize.length);
    } // validate each one of the dimension sizes


    for (var s = 0; s < asize.length; s++) {
      // must match
      if (asize[s] !== bsize[s]) {
        throw new RangeError('Dimension mismatch. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')');
      } // update dimension in c


      csize[s] = asize[s];
    } // datatype


    var dt; // callback signature to use

    var cf = callback; // process data types

    if (typeof adt === 'string' && adt === bdt) {
      // datatype
      dt = adt; // callback

      cf = typed.find(callback, [dt, dt]);
    } // populate cdata, iterate through dimensions


    var cdata = csize.length > 0 ? _iterate(cf, 0, csize, csize[0], adata, bdata) : []; // c matrix

    return new DenseMatrix({
      data: cdata,
      size: csize,
      datatype: dt
    });
  }
Iterates over DenseMatrix items and invokes the callback function f(Aij..z, Bij..z).
Callback function invoked MxN times.

C(i,j,...z) = f(Aij..z, Bij..z)

@param {Matrix}   a                 The DenseMatrix instance (A)
@param {Matrix}   b                 The DenseMatrix instance (B)
@param {Function} callback          The f(Aij..z,Bij..z) operation to invoke

@return {Matrix}                    DenseMatrix (C)

https://github.com/josdejong/mathjs/pull/346#issuecomment-97658658