Browse Source

Accelerate Newton's method for LiebLin by moving allocations up

master
J.-S. Caux 5 years ago
parent
commit
b5f3b0755c
2 changed files with 9 additions and 7 deletions
  1. 1
    1
      include/ABACUS_LiebLin.h
  2. 8
    6
      src/LIEBLIN/LiebLin_Bethe_State.cc

+ 1
- 1
include/ABACUS_LiebLin.h View File

@@ -82,7 +82,7 @@ namespace ABACUS {
82 82
     void Set_Free_lambdaocs();
83 83
     void Iterate_BAE(DP damping);
84 84
     void Iterate_BAE_S(DP damping);
85
-    void Iterate_BAE_Newton(DP damping);
85
+    void Iterate_BAE_Newton (DP damping, Vect_DP& RHSBAE, Vect_DP& dlambdaoc, SQMat_DP& Gaudin, Vect_INT& indx);
86 86
     void Compute_Energy ();
87 87
     void Compute_Momentum ();
88 88
     DP Kernel (int a, int b);

+ 8
- 6
src/LIEBLIN/LiebLin_Bethe_State.cc View File

@@ -275,8 +275,14 @@ namespace ABACUS {
275 275
 
276 276
     DP damping = 1.0;
277 277
     DP diffsq_prev = 1.0e+6;
278
+
279
+    Vect_DP RHSBAE (0.0, N);  // contains RHS of BAEs
280
+    Vect_DP dlambdaoc (0.0, N);  // contains delta lambdaoc computed from Newton's method
281
+    SQMat_DP Gaudin (0.0, N);
282
+    Vect_INT indx (N);
283
+
278 284
     while (diffsq > prec && !is_nan(diffsq) && iter_Newton < 100) {
279
-      (*this).Iterate_BAE_Newton(damping);
285
+      (*this).Iterate_BAE_Newton(damping, RHSBAE, dlambdaoc, Gaudin, indx);
280 286
       if (diffsq > diffsq_prev && damping > 0.5) damping /= 2.0;
281 287
       else if (diffsq < diffsq_prev) damping = 1.0;
282 288
       diffsq_prev = diffsq;
@@ -469,12 +475,8 @@ namespace ABACUS {
469 475
   /**
470 476
      Performs one step of the matrix Newton method on the rapidities.
471 477
    */
472
-  void LiebLin_Bethe_State::Iterate_BAE_Newton (DP damping)
478
+  void LiebLin_Bethe_State::Iterate_BAE_Newton (DP damping, Vect_DP& RHSBAE, Vect_DP& dlambdaoc, SQMat_DP& Gaudin, Vect_INT& indx)
473 479
   {
474
-    Vect_DP RHSBAE (0.0, N);  // contains RHS of BAEs
475
-    Vect_DP dlambdaoc (0.0, N);  // contains delta lambdaoc computed from Newton's method
476
-    SQMat_DP Gaudin (0.0, N);
477
-    Vect_INT indx (N);
478 480
     DP sumtheta = 0.0;
479 481
     // for large |lambda|, use atan (lambda) = sgn(lambda) pi/2 - atan(1/lambda)
480 482
     int atanintshift = 0;

Loading…
Cancel
Save