From df12df82c5932370148db4d8c724dc804d19a405 Mon Sep 17 00:00:00 2001 From: hunghaoti Date: Wed, 25 Oct 2023 09:59:37 +0800 Subject: [PATCH] Fix putblock error when dtype not same. --- tests/linalg_test/linalg_test.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/linalg_test/linalg_test.cpp b/tests/linalg_test/linalg_test.cpp index 614787b7..e4deeaf4 100644 --- a/tests/linalg_test/linalg_test.cpp +++ b/tests/linalg_test/linalg_test.cpp @@ -337,10 +337,11 @@ TEST_F(linalg_Test, BkUt_Norm) { Bond I = Bond(BD_IN, {Qs(-1), Qs(1)}, {3, 3}); Bond J = Bond(BD_OUT, {Qs(-1), Qs(1)}, {3, 3}); UniTensor in = UniTensor({I, J}); - in.put_block_(arange3x3cd, 0); - in.put_block_(ones3x3cd, 1); + auto cd_in = in.astype(Type.ComplexDouble); + cd_in.put_block_(arange3x3cd, 0); + cd_in.put_block_(ones3x3cd, 1); // EXPECT_EQ(cytnx_double(linalg::Norm(in).item().real()), ans); - EXPECT_TRUE(abs(cytnx_double(linalg::Norm(in).item().real()) - ans) < + EXPECT_TRUE(abs(cytnx_double(linalg::Norm(cd_in).item().real()) - ans) < 1e-13); // not sure why some precision lost. }