Calculate dot product (#608)