fix reduce for higher ranked arrays to iterate over the first axis, not total ravelled size.
fix dot for matrix multiply.