Skip to content

Commit bd19b48

Browse files
authored
Fix indptr overflow. (#6803)
1 parent 9ae2066 commit bd19b48

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

source/source_io/single_R_io.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66

77
inline void write_data(std::ofstream& ofs, const double& data)
88
{
9-
ofs << " " << std::fixed << std::scientific << std::setprecision(8) << data;
9+
ofs << " " << data;
1010
}
1111
inline void write_data(std::ofstream& ofs, const std::complex<double>& data)
1212
{
13-
ofs << " (" << std::fixed << std::scientific << std::setprecision(8) << data.real() << ","
14-
<< std::fixed << std::scientific << std::setprecision(8) << data.imag() << ")";
13+
ofs << " (" << data.real() << "," << data.imag() << ")";
1514
}
1615

1716
template<typename T>
@@ -68,7 +67,8 @@ void ModuleIO::output_single_R(std::ofstream& ofs,
6867

6968
if (!reduce || GlobalV::DRANK == 0)
7069
{
71-
int nonzeros_count = 0;
70+
long long nonzeros_count = 0;
71+
ofs << std::fixed << std::scientific << std::setprecision(8);
7272
for (int col = 0; col < PARAM.globalv.nlocal; ++col)
7373
{
7474
if (std::abs(line[col]) > sparse_threshold)
@@ -106,7 +106,7 @@ void ModuleIO::output_single_R(std::ofstream& ofs,
106106
ifs_tem1.close();
107107
for (auto &i : indptr)
108108
{
109-
ofs.write(reinterpret_cast<char *>(&i), sizeof(int));
109+
ofs.write(reinterpret_cast<char *>(&i), sizeof(long long));
110110
}
111111
}
112112
else

0 commit comments

Comments
 (0)