From 139eab0cbca5d19a8392569760e7cf215f1034d4 Mon Sep 17 00:00:00 2001 From: ErjieWu Date: Tue, 23 Dec 2025 13:34:53 +0800 Subject: [PATCH] Fix indptr overflow. --- source/source_io/single_R_io.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/source_io/single_R_io.cpp b/source/source_io/single_R_io.cpp index ff65386f1a..a8e7e3cace 100644 --- a/source/source_io/single_R_io.cpp +++ b/source/source_io/single_R_io.cpp @@ -6,12 +6,11 @@ inline void write_data(std::ofstream& ofs, const double& data) { - ofs << " " << std::fixed << std::scientific << std::setprecision(8) << data; + ofs << " " << data; } inline void write_data(std::ofstream& ofs, const std::complex& data) { - ofs << " (" << std::fixed << std::scientific << std::setprecision(8) << data.real() << "," - << std::fixed << std::scientific << std::setprecision(8) << data.imag() << ")"; + ofs << " (" << data.real() << "," << data.imag() << ")"; } template @@ -68,7 +67,8 @@ void ModuleIO::output_single_R(std::ofstream& ofs, if (!reduce || GlobalV::DRANK == 0) { - int nonzeros_count = 0; + long long nonzeros_count = 0; + ofs << std::fixed << std::scientific << std::setprecision(8); for (int col = 0; col < PARAM.globalv.nlocal; ++col) { if (std::abs(line[col]) > sparse_threshold) @@ -106,7 +106,7 @@ void ModuleIO::output_single_R(std::ofstream& ofs, ifs_tem1.close(); for (auto &i : indptr) { - ofs.write(reinterpret_cast(&i), sizeof(int)); + ofs.write(reinterpret_cast(&i), sizeof(long long)); } } else