diff --git a/include/hyperjet.h b/include/hyperjet.h index ed57052..fccfd72 100644 --- a/include/hyperjet.h +++ b/include/hyperjet.h @@ -587,14 +587,27 @@ class DDScalar { return result; } + Scalar t(0); + for (index i = 0; i < size(); i++) { - auto s = Scalar(0); - for (index j = 0; j < size(); j++) { - s += d[j] * h(i, j); + Scalar s(0); + + index k = 1 + size() + i; + + for (index j = 0; j < i; j++) { + s += d[j] * m_data[k]; + k += size() - j - 1; + } + + for (index j = i; j < size(); j++) { + s += d[j] * m_data[k++]; } - result += 0.5 * d[i] * s; + + t += d[i] * s; } + result += 0.5 * t; + return result; }