This file contains the comments of what has essentially changed during the
speed up of the code!!

Testsize: 1000
Two problems: alpha=1, diff_cut_crit=1;
              alpha=1D8, diff_cut_crit=10D-8;
P1: time: 9.960
    iterates: 2119
    accuracy: 0.5725 E-10
    --> lapack: 2.9390
    --> quasi: 0.5920
   
P2: time: 11.105
    iterates: 2295
    accuracy: 0.14E-7
    --> lapack: 3.002
    --> quasi: 0.6890

Every item represents the change and update of a specific piece of code.
New timing results are monitored, as well as accuracy and number of iterations.
It is indicated which file changed and what is done.

Important remark: 
 retrieve_eigenvalues is not always updated, since not incorporated in the timings.


%--------------------- Start making Improvements ------------------------
1. Makefile: -O3 -g   
   P1: time 4.48
       accuracy:  0.5725 E-10 (unchanged);
       iterations: 2119 (unchanged);
       --> lapack 2.9280
       --> quasi: 0.4270
   P2: time 4.98
       accuracy: 0.14E-7 (unchanged),
       iterations: 2295 (unchanged)
       --> lapack: 2.9690
       --> quasi: 0.4910

2. Altering the imput of eig_giv_weight,
   parameters can now be passed to eig_giv_weight
   P1: All unchanged;
   P2; All unchanged;

3. constructwindow.f90 (subroutine)
   (copied and checked from Profile_Code directory)
   P1; time: 3.9620 
       acc: 0.57E-10 (unchanged)
       itt: 2119 (unchanged)
   P2; time 4.4400
       acc: 0.14E-7 (unchanged)
       itt: 2295 (unchanged)

4. updaterepresentation.f90 (includefile)
   (copied from Profile_code directory)
   add variable th to qrstep.f90 (subroutine)
   P1; time: 3.7910
       acc: 0.57E-10 (unch)
       itt: 2119 (unch)
   P2; time: 4.208
       acc: 0.14E-7 (unch)
       itt: 2295 (unch)

5. retrievecolumn.f90 (subroutine)
   (copied from Profile_code directory)
   Changed parameters from input: no uv, v->v(col)
   Following files are altered:
   - computeshift.f90
   - deflate.f90
   - determine_chasing_GivI.f90
   - %--> NOTHING CHANGED: initialstep.f90:!!$  ! retrievecolumn to obtain a block
   - lastgivens.f90
   - qrstep.f90:call retrievecolumn(Uni,B,u,v,i1,n,x,uv);
   P1; time: 3.5420
       acc: 0.57E-10
       itt: 2119
   P2; time: 3.9210
       acc: 0.14E-7 (unch)
       itt: 2295

6. computeshift.f90 (include file, just changed parameter)
   deflate.f90 -> (include file, nothing changed)
   initialstep.f90 -> (include file, 1 matmul)
   P1; time: 3.5410
       acc: 0.57E-10
       itt: 2119
   P2; time: 3.9210
       acc: 0.14E-7 (unch)
       itt: 2295

7. performgivensright.f90 (include file)
   Copied from Profile_Code
   P1; time: 3.1370
       acc: 0.57E-10
       itt: 2119
   P2; time: 3.5090
       acc: 0.14E-7 (unch)
       itt: 2295

8. lastgivens.f90 (include file)
   Newly altered, many matmul and other alterations
   P1; time: 3.1200
       acc: 0.57E-10 (unch)
       itt: 2119 (unch)
   P2; time: 3.4880 
       acc: 0.14E-7 (unch)
       itt: 2295 (unch)

9. penultgiv.f90 (include file)
   Newly altered, many matmul and transpose
   P1; time: 3.1340 (increase!!)
       acc: 0.57E-10 (unch)
       itt: 2119 (unch)
   P2; time: 3.5010 (increase!!) 
       acc: 0.14E-7 (unch)
       itt: 2295 (unch)

10. determinechasing.f90
    matmul, transpose changed
   P1; time: 2.9440 (decrease!!)
       acc: 0.57E-10 (unch)
       itt: 2119 (unch)
   P2; time: 3.2850 (decrease!!) 
       acc: 0.14E-7 (unch)
       itt: 2295 (unch)

11. qrstep.f90 (transpose)
    determine_chasing_GivI (always performed for very big alpha, stability!)
    P1; time: 2.9310 (decrease!!, faster than lapack)
        acc: 0.57E-10 (unch)
        itt: 2119 (unch)
    P2; time: 3.2420 (decrease!!) 
        acc: 0.14E-7 (unch)
        itt: 2295 (unch)

12. givens.f90 (we take lucas implementation)
    P1; time: 2.5770 (decrease!!, faster than lapack)
        acc: 0.11E-10 (decrease)
        itt: 2116 (decrease)
    P2; time: 2.9230 (decrease!!) 
        acc: 0.14E-7 (unch)
        itt: 2313 (increase!!!)

13. ST.f90 (subroutine)
    ---> There is no significant indication that the transpose would increase
    stability! No transpose seems to be better! Perhaps there is an error. 
    Check this!!
    --> It seems there was an error, since we have rewritten the routine now.
    (still matmuls and transposes are present, but the routine works again)
    P1; time: 1.9440 (decrease !!!)
        acc: 0.17E-10 (almost unchanged)
        itt: 2124 (slight increase)
    P2; time: 2.2630 (decrease!!) 
        acc: 0.14E-7 (unch)
        itt: 2342 (increase!!!)
   --> CONCLUSION: taking the two options as presented in the routine ST, 
   does improve the accuracy (i did do some tests indicating it wrongly, probably
   i made a mistake, since in 14. we clearly see improvement of accuracy with 1 digit.)


14. ST.f90 (subroutine--> enhance speed)
    We will remove the matmuls and so forth.
    P1; time: 1.5830 (decrease !!!)
        acc: 0.119E-11 (almost unchanged)
        itt: 2124 (slight increase)
    P2; time: 1.8520 (decrease!!) 
        acc: 0.14E-7 (unch)
        itt: 2346 (unch)


15. Extra compiler option: -funroll-loops
    P1; time: 1.3710 (decrease !!!)
        acc: 0.119E-11 (almost unchanged)
        itt: 2124 (slight increase)
    P2; time: 1.6070 (decrease!!) 
        acc: 0.14E-7 (unch)
        itt: 2346 (unch)

16. Removal of reshape operator:
    determine_chasing_GivI.f90 --> removed reshape
    lastgivens.f90 --> removed reshape
    penultgiv.f90 --> removed reshape
    

17. Modifying ST.f90 (less operations for reshuffling)
    --> ST_comments contains the working version with much more text
    --> this text is removed in the actual ST.f90 operation
    P1; time: 1.4030 (slight increase!!)
        acc: 0.44E-12 (much much better)
        itt: 2124 (unchanged)
    ---> There seem to be problems
    P2; time: 1.6190 (light increase)
        acc: 0.14E-7 (unch)
        itt: 2332 (unch)

18. Modifying ST2.f90 (less operations and so forth, corresponding ST.f90)
    P1; time: 1.3680 (slight better!!)
        acc: 0.52E-12 (approx the same)
        itt: 2124 (unchaned)
    P2; time: 1.5310 (better)
        acc: 0.14E-7 (unch)
        itt: 2321 (better)

GIV--break--> Changes from this moment are not yet incorporated in 
the Givens representation.

19. Modifying ST.f90 --> Enhanced implementation form
    See the notes for details on how to reduce the complexity. 
    P1; time: 1.3360 (slight better!!)
        acc: 0.56E-12 (approx the same)
        itt: 2124 (unchaned)
    P2; time: 1.5420 (better)
        acc: 0.14E-7 (unch)
        itt: 2296 (better)
    
20. Retrievecolumn.f90 --> enhancement of computing the vector.
    less operations and less memory
    --> can perhaps be faster when written as two loops
    The function is rewritten and we get:
    P1; time: 1.3030 (slight better!!)
        acc: 0.56E-12 (approx the same)
        itt: 2124 (unchaned)
    P2; time: 1.4530 (better)
        acc: 0.14E-7 (unch)
        itt: 2301 (worse)

21. Check the subroutine structure:
    Do not define new variables in subroutines, it seems slow.
    --> When making an include file of qrstep, please remove it from the compilation list.     
    --> Changed a little the output format     
    --> Different compiler options

22. We perform some timings to see the speed
    n=100:  0.008       (la: 0.016       , factor 2)
    n=200:  0.028 (3.5) (la: 0.089 (5.5) , factor 3.1)
    n=400:  0.126 (4.5) (la: 0.503 (5.61), factor 3.99)
    n=800:  0.648 (5.1) (la: 1.99 (3.9)  , factor 3.1)
    n=1600: 3.781 (5.8) (la: 7.349(3.69) , factor 1.9)
    n=3200: 
    n=6400: 

23. We try to change many things in qrstep to functions to detect were it goes wrong
    ----> It was the reassignment of v to vwg, were it all went wrong. 
    Now the code is comparable to Luca's code, still a little little bit slower, 
    but neglectable. 
    We still need to tune many other things now, before we achieve the best speed. 
    Let us also try again to update the Givens implementation to see how that is 
    performing.
    P1; time: 0.4640 (much better!!)
        acc: 0.56E-12 (approx the same)
        itt: 2124 (unchaned)
    P2; time: 0.5330 (much better)
        acc: 0.14E-7 (unch)
        itt: 2216 (worse)
        

--> From this point we switch completely to the Givens implementation, since this is faster and more accurate.


--> Carefully check ST.f90
    Sometimes it is better to compute the Givens transformation, 
    instead of directly assigning, check carefully why!!!    

--> Change the order of the fastquasi and the Giv again

--> Improve still the copying in vwg.

--> Improve ST2.f90

--> For tests of the accuracy rebuild the matrix from the Givens-weight representation,
not from the u,v as luca does. this is good for comparing luca's results but not ours.
    Implement the different examples -> Only real!

%----------------------------------------------------------------------


To do before the code is finished:

- redundant parameters in routines?
  pass also all variables to subroutines.

- subroutines yes or no (slower or faster)?
  (perhaps there is too much copying or so)??
  try to remove the qrstep.f90 implementation

- chasingUni and fullChaGiv and fullG??? all necessary

- If several manipulations are done with i+1, better to create a new variable?
  Test in separate routine.

- accuracy of the givens implementation?

- ST --> Check pvd his implementation

- constructwindow--> Is it necessary to recompute the whole window each step??
  I think we can recover most of it....
  This is coupled with updaterepresentation.
  --> We completely rebuild everything, this is not necessary, the window slides, 
  hence no need to recompute it completely.

