Accelerate Newton's method for LiebLin by moving allocations up
This commit is contained in:
parent
565216ffdd
commit
b5f3b0755c
|
@ -82,7 +82,7 @@ namespace ABACUS {
|
||||||
void Set_Free_lambdaocs();
|
void Set_Free_lambdaocs();
|
||||||
void Iterate_BAE(DP damping);
|
void Iterate_BAE(DP damping);
|
||||||
void Iterate_BAE_S(DP damping);
|
void Iterate_BAE_S(DP damping);
|
||||||
void Iterate_BAE_Newton(DP damping);
|
void Iterate_BAE_Newton (DP damping, Vect_DP& RHSBAE, Vect_DP& dlambdaoc, SQMat_DP& Gaudin, Vect_INT& indx);
|
||||||
void Compute_Energy ();
|
void Compute_Energy ();
|
||||||
void Compute_Momentum ();
|
void Compute_Momentum ();
|
||||||
DP Kernel (int a, int b);
|
DP Kernel (int a, int b);
|
||||||
|
|
|
@ -275,8 +275,14 @@ namespace ABACUS {
|
||||||
|
|
||||||
DP damping = 1.0;
|
DP damping = 1.0;
|
||||||
DP diffsq_prev = 1.0e+6;
|
DP diffsq_prev = 1.0e+6;
|
||||||
|
|
||||||
|
Vect_DP RHSBAE (0.0, N); // contains RHS of BAEs
|
||||||
|
Vect_DP dlambdaoc (0.0, N); // contains delta lambdaoc computed from Newton's method
|
||||||
|
SQMat_DP Gaudin (0.0, N);
|
||||||
|
Vect_INT indx (N);
|
||||||
|
|
||||||
while (diffsq > prec && !is_nan(diffsq) && iter_Newton < 100) {
|
while (diffsq > prec && !is_nan(diffsq) && iter_Newton < 100) {
|
||||||
(*this).Iterate_BAE_Newton(damping);
|
(*this).Iterate_BAE_Newton(damping, RHSBAE, dlambdaoc, Gaudin, indx);
|
||||||
if (diffsq > diffsq_prev && damping > 0.5) damping /= 2.0;
|
if (diffsq > diffsq_prev && damping > 0.5) damping /= 2.0;
|
||||||
else if (diffsq < diffsq_prev) damping = 1.0;
|
else if (diffsq < diffsq_prev) damping = 1.0;
|
||||||
diffsq_prev = diffsq;
|
diffsq_prev = diffsq;
|
||||||
|
@ -469,12 +475,8 @@ namespace ABACUS {
|
||||||
/**
|
/**
|
||||||
Performs one step of the matrix Newton method on the rapidities.
|
Performs one step of the matrix Newton method on the rapidities.
|
||||||
*/
|
*/
|
||||||
void LiebLin_Bethe_State::Iterate_BAE_Newton (DP damping)
|
void LiebLin_Bethe_State::Iterate_BAE_Newton (DP damping, Vect_DP& RHSBAE, Vect_DP& dlambdaoc, SQMat_DP& Gaudin, Vect_INT& indx)
|
||||||
{
|
{
|
||||||
Vect_DP RHSBAE (0.0, N); // contains RHS of BAEs
|
|
||||||
Vect_DP dlambdaoc (0.0, N); // contains delta lambdaoc computed from Newton's method
|
|
||||||
SQMat_DP Gaudin (0.0, N);
|
|
||||||
Vect_INT indx (N);
|
|
||||||
DP sumtheta = 0.0;
|
DP sumtheta = 0.0;
|
||||||
// for large |lambda|, use atan (lambda) = sgn(lambda) pi/2 - atan(1/lambda)
|
// for large |lambda|, use atan (lambda) = sgn(lambda) pi/2 - atan(1/lambda)
|
||||||
int atanintshift = 0;
|
int atanintshift = 0;
|
||||||
|
|
Loading…
Reference in New Issue