From 9050cb0f14f61ef413e680aa0f08e0fffb1643aa Mon Sep 17 00:00:00 2001 From: "Robert J. Harrison" Date: Fri, 22 Sep 2023 16:47:03 -0400 Subject: [PATCH] fixing Florian's bug with overflow of norm for ints in test code --- src/madness/tensor/tensor.h | 6 +++--- src/madness/tensor/test_tensor.cc | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/madness/tensor/tensor.h b/src/madness/tensor/tensor.h index f160e097c17..73b3967ddba 100644 --- a/src/madness/tensor/tensor.h +++ b/src/madness/tensor/tensor.h @@ -257,11 +257,11 @@ namespace madness { } namespace detail { - template T mynorm(T t) { - return t*t; + template double mynorm(T t) { + return double(t)*t; } - template T mynorm(std::complex t) { + template double mynorm(std::complex t) { return std::norm(t); } } diff --git a/src/madness/tensor/test_tensor.cc b/src/madness/tensor/test_tensor.cc index 59790ab7e70..3c6a70552a7 100644 --- a/src/madness/tensor/test_tensor.cc +++ b/src/madness/tensor/test_tensor.cc @@ -53,13 +53,13 @@ namespace { return ((double) x)*x; } -// template <> double mynorm(float_complex x) { -// return (double) std::norm(x); -// } -// -// template <> double mynorm(double_complex x) { -// return (double) std::norm(x); -// } + template <> double mynorm(float_complex x) { + return (double) std::norm(x); + } + + template <> double mynorm(double_complex x) { + return (double) std::norm(x); + } template inline