Skip to content

Commit 53bc754

Browse files
committed
remove auto
1 parent b452a90 commit 53bc754

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

source/module_relax/relax_old/bfgs.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ void BFGS::allocate(const int _size)
1212
maxstep=PARAM.inp.relax_bfgs_rmax;
1313
size=_size;
1414
sign =true;
15-
1615
H = std::vector<std::vector<double>>(3*size, std::vector<double>(3*size, 0.0));
1716

1817
for (int i = 0; i < 3*size; ++i)
@@ -32,7 +31,6 @@ void BFGS::allocate(const int _size)
3231

3332

3433
void BFGS::relax_step(const ModuleBase::matrix& _force,UnitCell& ucell)
35-
3634
{
3735
GetPos(ucell,pos);
3836
GetPostaud(ucell,pos_taud);
@@ -171,7 +169,7 @@ void BFGS::Update(std::vector<double>& pos,
171169
return;
172170
}
173171
//std::vector<double> dpos=this->VSubV(pos,pos0);
174-
auto term=ReshapeMToV(pos_taud);
172+
std::vector<double> term=ReshapeMToV(pos_taud);
175173
std::vector<double> dpos = VSubV(term, pos_taud0);
176174
for(int i=0;i<3*size;i++)
177175
{
@@ -227,10 +225,10 @@ void BFGS::Update(std::vector<double>& pos,
227225
double a = DotInVAndV(dpos, dforce);
228226
std::vector<double> dg = DotInMAndV1(H, dpos);
229227
double b = DotInVAndV(dpos, dg);
230-
auto term1=OuterVAndV(dforce, dforce);
231-
auto term2=OuterVAndV(dg, dg);
232-
auto term3=MPlus(term1, a);
233-
auto term4=MPlus(term2, b);
228+
std::vector<std::vector<double>> term1=OuterVAndV(dforce, dforce);
229+
std::vector<std::vector<double>> term2=OuterVAndV(dg, dg);
230+
std::vector<std::vector<double>> term3=MPlus(term1, a);
231+
std::vector<std::vector<double>> term4=MPlus(term2, b);
234232
H = MSubM(H, term3);
235233
H = MSubM(H, term4);
236234
}
@@ -239,7 +237,7 @@ void BFGS::DetermineStep(std::vector<double>& steplength,
239237
std::vector<std::vector<double>>& dpos,
240238
double& maxstep)
241239
{
242-
auto maxsteplength = max_element(steplength.begin(), steplength.end());
240+
std::vector<double>::iterator maxsteplength = max_element(steplength.begin(), steplength.end());
243241
double a = *maxsteplength;
244242
if(a >= maxstep)
245243
{

source/module_relax/relax_old/lbfgs.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,24 +114,24 @@ void LBFGS::prepare_step(std::vector<std::vector<double>>& force,
114114
for(int i=loopmax-1;i>=0;i--)
115115
{
116116
a[i]=rho[i]*DotInVAndV(s[i],q);
117-
auto temp=DotInVAndFloat(y[i],a[i]);
117+
std::vector<double> temp=DotInVAndFloat(y[i],a[i]);
118118
q=VSubV(q,temp);
119119
}
120120
std::vector<double> z=DotInVAndFloat(q,H0);
121121
for(int i=0;i<loopmax;i++)
122122
{
123123
double b=rho[i]*DotInVAndV(y[i],z);
124-
auto temp=DotInVAndFloat(s[i],a[i]-b);
124+
std::vector<double> temp=DotInVAndFloat(s[i],a[i]-b);
125125
z=VAddV(z,temp);
126126
}
127-
auto temp0=DotInVAndFloat(z,-1);
127+
std::vector<double> temp0=DotInVAndFloat(z,-1);
128128
dpos=ReshapeVToM(temp0);
129-
auto temp1=DotInVAndFloat(changedforce,-1);
129+
std::vector<double> temp1=DotInVAndFloat(changedforce,-1);
130130
std::vector<std::vector<double>> g=ReshapeVToM(temp1);
131131
energy=etot;
132132
//alpha_k=l_search.line_search(ucell,pos,g,energy,maxstep,size,dpos,pos,solver);
133-
//auto temp2=DotInVAndFloat(temp0,alpha_k);
134-
auto temp2=DotInVAndFloat(temp0,1);
133+
//std::vector<double> temp2=DotInVAndFloat(temp0,alpha_k);
134+
std::vector<double> temp2=DotInVAndFloat(temp0,1);
135135
dpos=ReshapeVToM(temp2);
136136
for(int i = 0; i < size; i++)
137137
{
@@ -160,7 +160,7 @@ void LBFGS::update(std::vector<std::vector<double>>& pos_taud,
160160
{
161161
if(iteration>0)
162162
{
163-
auto term=ReshapeMToV(pos_taud);
163+
std::vector<double> term=ReshapeMToV(pos_taud);
164164
std::vector<double> dpos =VSubV(term, pos_taud0);
165165
for(int i=0;i<3*size;i++)
166166
{
@@ -221,7 +221,7 @@ void LBFGS::update(std::vector<std::vector<double>>& pos_taud,
221221
}
222222
void LBFGS::determine_step(std::vector<double>& steplength,std::vector<std::vector<double>>& dpos,double& maxstep)
223223
{
224-
auto maxsteplength = max_element(steplength.begin(), steplength.end());
224+
std::vector<double>::iterator maxsteplength = max_element(steplength.begin(), steplength.end());
225225
double a = *maxsteplength;
226226
if(a >= maxstep)
227227
{

0 commit comments

Comments
 (0)