Skip to content

Commit a26c68f

Browse files
committed
robustness fix for Neoverse-V2 platform
1 parent 313d6ab commit a26c68f

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

c++/algo_CFS.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Algo_CFSls : virtual public Algo<S> {
3434
const auto term1 = [&diagI1, &diagIp, Z=stats.Zft, &op1, &op2, T = P.T.value(), this](const auto r1, const auto rp) {
3535
const auto E1 = diagI1.values.abs_zero(r1);
3636
const auto Ep = diagIp.values.abs_zero(rp);
37-
const auto weight = conj_me(op1(r1, rp)) * op2(r1, rp) * exp(-E1/T) * (-sign)/Z;
37+
const auto weight = conj_me(op1(r1, rp)) * op2(r1, rp) * myexp(-E1/T) * (-sign)/Z;
3838
return std::make_pair(E1-Ep, weight);
3939
};
4040
for (const auto r1: diagI1.kept())
@@ -86,7 +86,7 @@ class Algo_CFSgt : virtual public Algo<S> {
8686
const auto term1 = [&diagI1, &diagIp, Z=stats.Zft, &op1, &op2, T = P.T.value()](const auto r1, const auto rp) {
8787
const auto E1 = diagI1.values.abs_zero(r1);
8888
const auto Ep = diagIp.values.abs_zero(rp);
89-
const auto weight = conj_me(op1(r1, rp)) * op2(r1, rp) * exp(-Ep/T)/Z;
89+
const auto weight = conj_me(op1(r1, rp)) * op2(r1, rp) * myexp(-Ep/T)/Z;
9090
return std::make_pair(E1-Ep, weight);
9191
};
9292
for (const auto r1: diagI1.kept())

c++/numerics.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,14 @@ void check_diag(const RVector &val, const Matrix &vec) {
382382
assert(is_unitary<S>(vec));
383383
}
384384

385+
inline double myexp(double x) {
386+
if (x < -700)
387+
return 0.0;
388+
if (x > 700)
389+
throw std::runtime_error("myexp trap");
390+
return std::exp(x);
391+
}
392+
385393
} // namespace
386394

387395
#endif

0 commit comments

Comments
 (0)