improved block-wise dot product to deal with cases where single rows/columns of input matrix are too big to fit in memory