Calculate scalar triple product (#618)