@@ -1060,14 +1060,15 @@ class DeepPot {
10601060 const int &nloc,
10611061 const std::vector<VALUETYPE> &fparam,
10621062 const std::vector<VALUETYPE> &aparam) const {
1063- if (fparam.size () != dfparam && fparam.size () != nframes * dfparam) {
1063+ if (fparam.size () != dfparam &&
1064+ fparam.size () != static_cast <size_t >(nframes) * dfparam) {
10641065 throw deepmd::hpp::deepmd_exception (
10651066 " the dim of frame parameter provided is not consistent with what the "
10661067 " model uses" );
10671068 }
10681069
1069- if (aparam.size () != daparam * nloc &&
1070- aparam.size () != nframes * daparam * nloc) {
1070+ if (aparam.size () != static_cast < size_t >( daparam) * nloc &&
1071+ aparam.size () != static_cast < size_t >( nframes) * daparam * nloc) {
10711072 throw deepmd::hpp::deepmd_exception (
10721073 " the dim of atom parameter provided is not consistent with what the "
10731074 " model uses" );
@@ -1081,9 +1082,10 @@ class DeepPot {
10811082 if (param.size () == dparam) {
10821083 out_param.resize (static_cast <size_t >(nframes) * dparam);
10831084 for (int ii = 0 ; ii < nframes; ++ii) {
1084- std::copy (param.begin (), param.end (), out_param.begin () + ii * dparam);
1085+ std::copy (param.begin (), param.end (),
1086+ out_param.begin () + static_cast <std::ptrdiff_t >(ii) * dparam);
10851087 }
1086- } else if (param.size () == nframes * dparam) {
1088+ } else if (param.size () == static_cast < size_t >( nframes) * dparam) {
10871089 out_param = param;
10881090 }
10891091 }
@@ -1184,7 +1186,8 @@ class DeepPotModelDevi {
11841186
11851187 // memory will be continous for std::vector but not std::vector<std::vector>
11861188 std::vector<double > energy_flat (numb_models);
1187- std::vector<VALUETYPE> force_flat (numb_models * natoms * 3 );
1189+ std::vector<VALUETYPE> force_flat (static_cast <size_t >(numb_models) *
1190+ natoms * 3 );
11881191 std::vector<VALUETYPE> virial_flat (numb_models * 9 );
11891192 double *ener_ = &energy_flat[0 ];
11901193 VALUETYPE *force_ = &force_flat[0 ];
@@ -1260,10 +1263,13 @@ class DeepPotModelDevi {
12601263 const int *atype_ = &atype[0 ];
12611264
12621265 std::vector<double > energy_flat (numb_models);
1263- std::vector<VALUETYPE> force_flat (numb_models * natoms * 3 );
1266+ std::vector<VALUETYPE> force_flat (static_cast <size_t >(numb_models) *
1267+ natoms * 3 );
12641268 std::vector<VALUETYPE> virial_flat (numb_models * 9 );
1265- std::vector<VALUETYPE> atom_energy_flat (numb_models * natoms);
1266- std::vector<VALUETYPE> atom_virial_flat (numb_models * natoms * 9 );
1269+ std::vector<VALUETYPE> atom_energy_flat (static_cast <size_t >(numb_models) *
1270+ natoms);
1271+ std::vector<VALUETYPE> atom_virial_flat (static_cast <size_t >(numb_models) *
1272+ natoms * 9 );
12671273 double *ener_ = &energy_flat[0 ];
12681274 VALUETYPE *force_ = &force_flat[0 ];
12691275 VALUETYPE *virial_ = &virial_flat[0 ];
@@ -1402,8 +1408,8 @@ class DeepPotModelDevi {
14021408
14031409 for (unsigned ii = 0 ; ii < numb_models; ++ii) {
14041410 for (unsigned jj = 0 ; jj < nloc; ++jj) {
1405- const VALUETYPE *tmp_f = &(xx[ii][jj * stride]);
1406- const VALUETYPE *tmp_avg = &(avg[jj * stride]);
1411+ const VALUETYPE *tmp_f = &(xx[ii][static_cast < size_t >(jj) * stride]);
1412+ const VALUETYPE *tmp_avg = &(avg[static_cast < size_t >(jj) * stride]);
14071413 for (unsigned dd = 0 ; dd < stride; ++dd) {
14081414 VALUETYPE vdiff = tmp_f[dd] - tmp_avg[dd];
14091415 std[jj] += vdiff * vdiff;
@@ -1432,7 +1438,7 @@ class DeepPotModelDevi {
14321438 assert (nloc * stride == ndof);
14331439
14341440 for (unsigned ii = 0 ; ii < nloc; ++ii) {
1435- const VALUETYPE *tmp_avg = &(avg[ii * stride]);
1441+ const VALUETYPE *tmp_avg = &(avg[static_cast < size_t >(ii) * stride]);
14361442 VALUETYPE f_norm = 0.0 ;
14371443 for (unsigned dd = 0 ; dd < stride; ++dd) {
14381444 f_norm += tmp_avg[dd] * tmp_avg[dd];
@@ -1477,14 +1483,15 @@ class DeepPotModelDevi {
14771483 const int &nloc,
14781484 const std::vector<VALUETYPE> &fparam,
14791485 const std::vector<VALUETYPE> &aparam) const {
1480- if (fparam.size () != dfparam && fparam.size () != nframes * dfparam) {
1486+ if (fparam.size () != dfparam &&
1487+ fparam.size () != static_cast <size_t >(nframes) * dfparam) {
14811488 throw deepmd::hpp::deepmd_exception (
14821489 " the dim of frame parameter provided is not consistent with what the "
14831490 " model uses" );
14841491 }
14851492
1486- if (aparam.size () != daparam * nloc &&
1487- aparam.size () != nframes * daparam * nloc) {
1493+ if (aparam.size () != static_cast < size_t >( daparam) * nloc &&
1494+ aparam.size () != static_cast < size_t >( nframes) * daparam * nloc) {
14881495 throw deepmd::hpp::deepmd_exception (
14891496 " the dim of atom parameter provided is not consistent with what the "
14901497 " model uses" );
@@ -1498,9 +1505,10 @@ class DeepPotModelDevi {
14981505 if (param.size () == dparam) {
14991506 out_param.resize (static_cast <size_t >(nframes) * dparam);
15001507 for (int ii = 0 ; ii < nframes; ++ii) {
1501- std::copy (param.begin (), param.end (), out_param.begin () + ii * dparam);
1508+ std::copy (param.begin (), param.end (),
1509+ out_param.begin () + static_cast <std::ptrdiff_t >(ii) * dparam);
15021510 }
1503- } else if (param.size () == nframes * dparam) {
1511+ } else if (param.size () == static_cast < size_t >( nframes) * dparam) {
15041512 out_param = param;
15051513 }
15061514 }
0 commit comments