@@ -644,8 +644,8 @@ class DeepPot {
644644 const VALUETYPE *box_ = !box.empty () ? &box[0 ] : nullptr ;
645645 const int *atype_ = &atype[0 ];
646646 double *ener_ = _DP_Get_Energy_Pointer (ener, nframes);
647- force.resize (nframes * natoms * 3 );
648- virial.resize (nframes * 9 );
647+ force.resize (static_cast < size_t >( nframes) * natoms * 3 );
648+ virial.resize (static_cast < size_t >( nframes) * 9 );
649649 VALUETYPE *force_ = &force[0 ];
650650 VALUETYPE *virial_ = &virial[0 ];
651651 std::vector<VALUETYPE> fparam_, aparam_;
@@ -706,10 +706,10 @@ class DeepPot {
706706 const int *atype_ = &atype[0 ];
707707
708708 double *ener_ = _DP_Get_Energy_Pointer (ener, nframes);
709- force.resize (nframes * natoms * 3 );
710- virial.resize (nframes * 9 );
711- atom_energy.resize (nframes * natoms);
712- atom_virial.resize (nframes * natoms * 9 );
709+ force.resize (static_cast < size_t >( nframes) * natoms * 3 );
710+ virial.resize (static_cast < size_t >( nframes) * 9 );
711+ atom_energy.resize (static_cast < size_t >( nframes) * natoms);
712+ atom_virial.resize (static_cast < size_t >( nframes) * natoms * 9 );
713713 VALUETYPE *force_ = &force[0 ];
714714 VALUETYPE *virial_ = &virial[0 ];
715715 VALUETYPE *atomic_ener_ = &atom_energy[0 ];
@@ -774,8 +774,8 @@ class DeepPot {
774774 const VALUETYPE *box_ = !box.empty () ? &box[0 ] : nullptr ;
775775 const int *atype_ = &atype[0 ];
776776 double *ener_ = _DP_Get_Energy_Pointer (ener, nframes);
777- force.resize (nframes * natoms * 3 );
778- virial.resize (nframes * 9 );
777+ force.resize (static_cast < size_t >( nframes) * natoms * 3 );
778+ virial.resize (static_cast < size_t >( nframes) * 9 );
779779 VALUETYPE *force_ = &force[0 ];
780780 VALUETYPE *virial_ = &virial[0 ];
781781 std::vector<VALUETYPE> fparam_, aparam_;
@@ -845,10 +845,10 @@ class DeepPot {
845845 const int *atype_ = &atype[0 ];
846846
847847 double *ener_ = _DP_Get_Energy_Pointer (ener, nframes);
848- force.resize (nframes * natoms * 3 );
849- virial.resize (nframes * 9 );
850- atom_energy.resize (nframes * natoms);
851- atom_virial.resize (nframes * natoms * 9 );
848+ force.resize (static_cast < size_t >( nframes) * natoms * 3 );
849+ virial.resize (static_cast < size_t >( nframes) * 9 );
850+ atom_energy.resize (static_cast < size_t >( nframes) * natoms);
851+ atom_virial.resize (static_cast < size_t >( nframes) * natoms * 9 );
852852 VALUETYPE *force_ = &force[0 ];
853853 VALUETYPE *virial_ = &virial[0 ];
854854 VALUETYPE *atomic_ener_ = &atom_energy[0 ];
@@ -910,8 +910,8 @@ class DeepPot {
910910 const VALUETYPE *box_ = !box.empty () ? &box[0 ] : nullptr ;
911911 const int *atype_ = &atype[0 ];
912912 double *ener_ = _DP_Get_Energy_Pointer (ener, nframes);
913- force.resize (nframes * natoms * 3 );
914- virial.resize (nframes * 9 );
913+ force.resize (static_cast < size_t >( nframes) * natoms * 3 );
914+ virial.resize (static_cast < size_t >( nframes) * 9 );
915915 VALUETYPE *force_ = &force[0 ];
916916 VALUETYPE *virial_ = &virial[0 ];
917917 std::vector<VALUETYPE> fparam_, aparam_;
@@ -972,10 +972,10 @@ class DeepPot {
972972 const int *atype_ = &atype[0 ];
973973
974974 double *ener_ = _DP_Get_Energy_Pointer (ener, nframes);
975- force.resize (nframes * natoms * 3 );
976- virial.resize (nframes * 9 );
977- atom_energy.resize (nframes * natoms);
978- atom_virial.resize (nframes * natoms * 9 );
975+ force.resize (static_cast < size_t >( nframes) * natoms * 3 );
976+ virial.resize (static_cast < size_t >( nframes) * 9 );
977+ atom_energy.resize (static_cast < size_t >( nframes) * natoms);
978+ atom_virial.resize (static_cast < size_t >( nframes) * natoms * 9 );
979979 VALUETYPE *force_ = &force[0 ];
980980 VALUETYPE *virial_ = &virial[0 ];
981981 VALUETYPE *atomic_ener_ = &atom_energy[0 ];
@@ -1079,7 +1079,7 @@ class DeepPot {
10791079 const int &dparam,
10801080 const std::vector<VALUETYPE> ¶m) const {
10811081 if (param.size () == dparam) {
1082- out_param.resize (nframes * dparam);
1082+ out_param.resize (static_cast < size_t >( nframes) * dparam);
10831083 for (int ii = 0 ; ii < nframes; ++ii) {
10841084 std::copy (param.begin (), param.end (), out_param.begin () + ii * dparam);
10851085 }
@@ -1210,7 +1210,7 @@ class DeepPotModelDevi {
12101210 virial.resize (numb_models);
12111211 for (int i = 0 ; i < numb_models; i++) {
12121212 ener[i] = energy_flat[i];
1213- force[i].resize (natoms * 3 );
1213+ force[i].resize (static_cast < size_t >( natoms) * 3 );
12141214 virial[i].resize (9 );
12151215 for (int j = 0 ; j < natoms * 3 ; j++) {
12161216 force[i][j] = force_flat[i * natoms * 3 + j];
@@ -1292,10 +1292,10 @@ class DeepPotModelDevi {
12921292 atom_virial.resize (numb_models);
12931293 for (int i = 0 ; i < numb_models; i++) {
12941294 ener[i] = energy_flat[i];
1295- force[i].resize (natoms * 3 );
1295+ force[i].resize (static_cast < size_t >( natoms) * 3 );
12961296 virial[i].resize (9 );
12971297 atom_energy[i].resize (natoms);
1298- atom_virial[i].resize (natoms * 9 );
1298+ atom_virial[i].resize (static_cast < size_t >( natoms) * 9 );
12991299 for (int j = 0 ; j < natoms * 3 ; j++) {
13001300 force[i][j] = force_flat[i * natoms * 3 + j];
13011301 }
@@ -1496,7 +1496,7 @@ class DeepPotModelDevi {
14961496 const int &dparam,
14971497 const std::vector<VALUETYPE> ¶m) const {
14981498 if (param.size () == dparam) {
1499- out_param.resize (nframes * dparam);
1499+ out_param.resize (static_cast < size_t >( nframes) * dparam);
15001500 for (int ii = 0 ; ii < nframes; ++ii) {
15011501 std::copy (param.begin (), param.end (), out_param.begin () + ii * dparam);
15021502 }
@@ -1653,8 +1653,8 @@ class DeepTensor {
16531653 const VALUETYPE *box_ = !box.empty () ? &box[0 ] : nullptr ;
16541654 const int *atype_ = &atype[0 ];
16551655 global_tensor.resize (odim);
1656- force.resize (odim * natoms * 3 );
1657- virial.resize (odim * 9 );
1656+ force.resize (static_cast < size_t >( odim) * natoms * 3 );
1657+ virial.resize (static_cast < size_t >( odim) * 9 );
16581658 VALUETYPE *global_tensor_ = &global_tensor[0 ];
16591659 VALUETYPE *force_ = &force[0 ];
16601660 VALUETYPE *virial_ = &virial[0 ];
@@ -1697,9 +1697,9 @@ class DeepTensor {
16971697 const int *atype_ = &atype[0 ];
16981698
16991699 global_tensor.resize (odim);
1700- force.resize (odim * natoms * 3 );
1701- virial.resize (odim * 9 );
1702- atom_virial.resize (odim * natoms * 9 );
1700+ force.resize (static_cast < size_t >( odim) * natoms * 3 );
1701+ virial.resize (static_cast < size_t >( odim) * 9 );
1702+ atom_virial.resize (static_cast < size_t >( odim) * natoms * 9 );
17031703 VALUETYPE *global_tensor_ = &global_tensor[0 ];
17041704 VALUETYPE *force_ = &force[0 ];
17051705 VALUETYPE *virial_ = &virial[0 ];
@@ -1752,8 +1752,8 @@ class DeepTensor {
17521752 const VALUETYPE *box_ = !box.empty () ? &box[0 ] : nullptr ;
17531753 const int *atype_ = &atype[0 ];
17541754 global_tensor.resize (odim);
1755- force.resize (odim * natoms * 3 );
1756- virial.resize (odim * 9 );
1755+ force.resize (static_cast < size_t >( odim) * natoms * 3 );
1756+ virial.resize (static_cast < size_t >( odim) * 9 );
17571757 VALUETYPE *global_tensor_ = &global_tensor[0 ];
17581758 VALUETYPE *force_ = &force[0 ];
17591759 VALUETYPE *virial_ = &virial[0 ];
@@ -1800,9 +1800,9 @@ class DeepTensor {
18001800 const int *atype_ = &atype[0 ];
18011801
18021802 global_tensor.resize (odim);
1803- force.resize (odim * natoms * 3 );
1804- virial.resize (odim * 9 );
1805- atom_virial.resize (odim * natoms * 9 );
1803+ force.resize (static_cast < size_t >( odim) * natoms * 3 );
1804+ virial.resize (static_cast < size_t >( odim) * 9 );
1805+ atom_virial.resize (static_cast < size_t >( odim) * natoms * 9 );
18061806 VALUETYPE *global_tensor_ = &global_tensor[0 ];
18071807 VALUETYPE *force_ = &force[0 ];
18081808 VALUETYPE *virial_ = &virial[0 ];
@@ -1954,7 +1954,7 @@ class DipoleChargeModifier {
19541954 const int *dpairs = reinterpret_cast <const int *>(&pairs[0 ]);
19551955 const VALUETYPE *delef = &delef_[0 ];
19561956
1957- dfcorr_.resize (natoms * 3 );
1957+ dfcorr_.resize (static_cast < size_t >( natoms) * 3 );
19581958 dvcorr_.resize (9 );
19591959 VALUETYPE *dfcorr = &dfcorr_[0 ];
19601960 VALUETYPE *dvcorr = &dvcorr_[0 ];
@@ -2071,7 +2071,7 @@ void select_map(std::vector<VT> &out,
20712071 nall2++;
20722072 }
20732073 }
2074- out.resize (nall2 * stride);
2074+ out.resize (static_cast < size_t >( nall2) * stride);
20752075 DP_SelectMapInt (&in[0 ], &fwd_map[0 ], stride, nall1, nall2, &out[0 ]);
20762076};
20772077
0 commit comments