@@ -115,32 +115,20 @@ void LCAO_Matrix::allocate_HS_k(const long &nloc)
115115void LCAO_Matrix::allocate_HS_R (const int &nnR)
116116{
117117 if (GlobalV::NSPIN!=4 )
118- {
119- delete[] HlocR;
120- delete[] SlocR;
121- delete[] Hloc_fixedR;
122-
123- this ->HlocR = new double [nnR];
124- this ->SlocR = new double [nnR];
125- this ->Hloc_fixedR = new double [nnR];
118+ {
119+ this ->SlocR .resize (nnR);
120+ this ->Hloc_fixedR .resize (nnR);
126121
127- ModuleBase::GlobalFunc::ZEROS (HlocR, nnR);
128- ModuleBase::GlobalFunc::ZEROS (SlocR, nnR);
129- ModuleBase::GlobalFunc::ZEROS (Hloc_fixedR, nnR);
122+ ModuleBase::GlobalFunc::ZEROS (SlocR.data (), nnR);
123+ ModuleBase::GlobalFunc::ZEROS (Hloc_fixedR.data (), nnR);
130124 }
131125 else
132126 {
133- delete[] HlocR_soc;
134- delete[] SlocR_soc;
135- delete[] Hloc_fixedR_soc;
136-
137- this ->HlocR_soc = new std::complex <double >[nnR];
138- this ->SlocR_soc = new std::complex <double >[nnR];
139- this ->Hloc_fixedR_soc = new std::complex <double >[nnR];
127+ this ->SlocR_soc .resize (nnR);
128+ this ->Hloc_fixedR_soc .resize (nnR);
140129
141- ModuleBase::GlobalFunc::ZEROS (HlocR_soc, nnR);
142- ModuleBase::GlobalFunc::ZEROS (SlocR_soc, nnR);
143- ModuleBase::GlobalFunc::ZEROS (Hloc_fixedR_soc, nnR);
130+ ModuleBase::GlobalFunc::ZEROS (SlocR_soc.data (), nnR);
131+ ModuleBase::GlobalFunc::ZEROS (Hloc_fixedR_soc.data (), nnR);
144132
145133 }
146134
@@ -358,33 +346,31 @@ void LCAO_Matrix::set_stress
358346
359347void LCAO_Matrix::zeros_HSgamma (const char &mtype)
360348{
361- if (mtype==' S' ) ModuleBase::GlobalFunc::ZEROS (Sloc.data (),GlobalC::ParaO. nloc );
362- else if (mtype==' T' ) ModuleBase::GlobalFunc::ZEROS (Hloc_fixed.data (),GlobalC::ParaO. nloc );
363- else if (mtype==' H' ) ModuleBase::GlobalFunc::ZEROS (Hloc.data (),GlobalC::ParaO. nloc );
349+ if (mtype==' S' ) ModuleBase::GlobalFunc::ZEROS (this -> Sloc .data (), this -> Sloc . size () );
350+ else if (mtype==' T' ) ModuleBase::GlobalFunc::ZEROS (this -> Hloc_fixed .data (), this -> Hloc_fixed . size () );
351+ else if (mtype==' H' ) ModuleBase::GlobalFunc::ZEROS (this -> Hloc .data (), this -> Hloc . size () );
364352 return ;
365353}
366354
367355void LCAO_Matrix::zeros_HSk (const char &mtype)
368356{
369- if (mtype==' S' ) ModuleBase::GlobalFunc::ZEROS (Sloc2.data (),GlobalC::ParaO. nloc );
370- else if (mtype==' T' ) ModuleBase::GlobalFunc::ZEROS (Hloc_fixed2.data (),GlobalC::ParaO. nloc );
371- else if (mtype==' H' ) ModuleBase::GlobalFunc::ZEROS (Hloc2.data (),GlobalC::ParaO. nloc );
357+ if (mtype==' S' ) ModuleBase::GlobalFunc::ZEROS (this -> Sloc2 .data (), this -> Sloc2 . size () );
358+ else if (mtype==' T' ) ModuleBase::GlobalFunc::ZEROS (this -> Hloc_fixed2 .data (), this -> Hloc_fixed2 . size () );
359+ else if (mtype==' H' ) ModuleBase::GlobalFunc::ZEROS (this -> Hloc2 .data (), this -> Hloc2 . size () );
372360 return ;
373361}
374362
375- void LCAO_Matrix::zeros_HSR (const char &mtype, const int &nnr )
363+ void LCAO_Matrix::zeros_HSR (const char &mtype)
376364{
377365 if (GlobalV::NSPIN!=4 )
378366 {
379- if (mtype==' S' ) ModuleBase::GlobalFunc::ZEROS (SlocR, nnr);
380- else if (mtype==' T' ) ModuleBase::GlobalFunc::ZEROS (Hloc_fixedR, nnr);
381- else if (mtype==' H' ) ModuleBase::GlobalFunc::ZEROS (HlocR, nnr);
367+ if (mtype==' S' ) ModuleBase::GlobalFunc::ZEROS (this ->SlocR .data (), this ->SlocR .size ());
368+ else if (mtype==' T' ) ModuleBase::GlobalFunc::ZEROS (this ->Hloc_fixedR .data (), this ->Hloc_fixedR .size ());
382369 }
383370 else
384371 {
385- if (mtype==' H' ) ModuleBase::GlobalFunc::ZEROS (this ->HlocR_soc , nnr);
386- else if (mtype==' S' ) ModuleBase::GlobalFunc::ZEROS (this ->SlocR_soc , nnr);
387- else if (mtype==' T' ) ModuleBase::GlobalFunc::ZEROS (this ->Hloc_fixedR_soc , nnr);
372+ if (mtype==' S' ) ModuleBase::GlobalFunc::ZEROS (this ->SlocR_soc .data (), this ->SlocR_soc .size ());
373+ else if (mtype==' T' ) ModuleBase::GlobalFunc::ZEROS (this ->Hloc_fixedR_soc .data (), this ->Hloc_fixedR_soc .size ());
388374 }
389375 return ;
390376}
0 commit comments