Add a scalarproduct implementation without list comprehensions