Skip to content

Commit 6540516

Browse files
authored
Update bfgs.cpp
use size_t to avoid risk only use static_cast to 3 in order to make sure calculation won't overflow
1 parent 9f550b3 commit 6540516

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

source/source_relax/bfgs.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "source_cell/update_cell.h"
66
#include "source_cell/print_cell.h" // lanshuyue add 2025-06-19
77

8+
89
//! initialize H0、H、pos0、force0、force
910
void BFGS::allocate(const int _size)
1011
{
@@ -128,7 +129,7 @@ void BFGS::PrepareStep(std::vector<ModuleBase::Vector3<double>>& force,
128129
//! call dysev
129130
std::vector<double> omega(3*size);
130131
std::vector<double> work(3*size*3*size);
131-
int lwork=3*size*3*size;
132+
size_t lwork=static_cast<size_t>(3)*size*3*size;
132133
int info=0;
133134
std::vector<double> H_flat;
134135

0 commit comments

Comments
 (0)