Hi, If this works, that'd be a great speed up! For the t_mat matrix, maybe you could name it as the evolution_matrix. That would make it clear as to what it really is. Remember that long and descriptive variable/class/function/method names are a feature of the relax source code - with the aim of helping new developers and/or power users to be able to read the code as text. See the "Long names" subsection at the end of http://www.nmr-relax.com/manual/Variable_function_class_names.html. Also, the following extensions of your current improvements would make things a lot quicker: 1) Create the evolution_matrix data structure at the start before the loop. Maybe with "evolution_matrix = R * 0.0" to create an empty structure. This, together with the following points, will ensure that only one data structure is created and deleted for the magnetisation evolution for one target function call, rather than the 100+ created and garbage collected at the moment. 2) Use the out argument: dot(Rexpo, r180x, evolution_matrix) dot(evolution_matrix, Rexpo, evolution_matrix) 3) The operation "t_mat = Rexpo.dot(r180x).dot(Rexpo).dot(Rexpo).dot(r180x).dot(Rexpo).dot(Rexpo).dot(r180x).dot(Rexpo).dot(Rexpo).dot(r180x).dot(Rexpo)" is 4x repetitive, so we can use that to minimise the operations. Starting from the evolution matrix created in point 2), you just need this 4 times, which you can do quickly with the following curious looking two lines: dot(evolution_matrix, evolution_matrix, evolution_matrix) dot(evolution_matrix, evolution_matrix, evolution_matrix) The first doubles the matrix block from Rexpo.r180x.Rexpo to Rexpo.r180x.Rexpo.Rexpo.r180x.Rexpo, and the second line doubles that again to Rexpo.r180x.Rexpo.Rexpo.r180x.Rexpo.Rexpo.r180x.Rexpo.Rexpo.r180x.Rexpo. By counting the dot products in the above steps, you can see that there are only 4 compared to the current 11 in the disp_spin_speed branch. And as the dot() call with out argument seems to be twice as fast (https://gna.org/task/index.php?7807#comment199), this should massively help your speed ambitions :) Regards, Edward On 15 June 2014 08:53, <tlinnet@xxxxxxxxxxxxx> wrote:
Author: tlinnet Date: Sun Jun 15 08:53:45 2014 New Revision: 23956 URL: http://svn.gna.org/viewcvs/relax?rev=23956&view=rev Log: Lowered the number of dot operations, by pre-preparing the evolution matrix another round. The power is in system tests always even. The trick to removing this for loop, would be to make a general multi dot function. Task #7807 (https://gna.org/task/index.php?7807): Speed-up of dispersion models for Clustered analysis. Modified: branches/disp_spin_speed/lib/dispersion/ns_cpmg_2site_3d.py Modified: branches/disp_spin_speed/lib/dispersion/ns_cpmg_2site_3d.py URL: http://svn.gna.org/viewcvs/relax/branches/disp_spin_speed/lib/dispersion/ns_cpmg_2site_3d.py?rev=23956&r1=23955&r2=23956&view=diff ============================================================================== --- branches/disp_spin_speed/lib/dispersion/ns_cpmg_2site_3d.py (original) +++ branches/disp_spin_speed/lib/dispersion/ns_cpmg_2site_3d.py Sun Jun 15 08:53:45 2014 @@ -138,10 +138,10 @@ Rexpo = matrix_exponential(R*tcp[i]) # Temp matrix. - t_mat = Rexpo.dot(r180x).dot(Rexpo).dot(Rexpo).dot(r180x).dot(Rexpo) + t_mat = Rexpo.dot(r180x).dot(Rexpo).dot(Rexpo).dot(r180x).dot(Rexpo).dot(Rexpo).dot(r180x).dot(Rexpo).dot(Rexpo).dot(r180x).dot(Rexpo) # Loop over the CPMG elements, propagating the magnetisation. - for j in range(power[i]): + for j in range(power[i]/2): Mint = t_mat.dot(Mint) # The next lines calculate the R2eff using a two-point approximation, i.e. assuming that the decay is mono-exponential. _______________________________________________ relax (http://www.nmr-relax.com) This is the relax-commits mailing list relax-commits@xxxxxxx To unsubscribe from this list, get a password reminder, or change your subscription options, visit the list information page at https://mail.gna.org/listinfo/relax-commits