Hi Troels,

Can this reshape happen in the target function __init__() method
instead, directly where M0 is initialised, i.e. "self.M0 = zeros((7,
1), float64)"?  That would be faster by avoiding this operation in the
target function calls, though considering how slow the rest of the
numeric model code is, you won't see a difference.  But it would be
cleaner, as M0 will remain in the same state throughout.

On a different note, you could initialise Mint storage outside of this
loop with "Mint = 1.0 * M0", and then use the numpy.dot() out argument
to replace:

Mint = t_mat.dot(Mint)

with:

dot(t_mat, Mint, Mint)

Though it looks like it is doing the same thing, the second option is
always faster.  In the first option, the dot product is more involved.
First it actually creates a completely new data structure for
"t_max.Mint", allocating new memory for it.  Then it replaces the
original Mint structure with the new structure (which are located in
different parts of the memory, this is just a pointer change), hence
the original Mint structure is garbage collected (the memory is
freed).  The second option with the out argument avoids the new memory
allocation and garbage collection by reusing the original Mint memory
allocation.

Regards,

Edward

On 15 June 2014 08:53,  <[email protected]> wrote:
> Author: tlinnet
> Date: Sun Jun 15 08:53:44 2014
> New Revision: 23955
>
> URL: http://svn.gna.org/viewcvs/relax?rev=23955&view=rev
> Log:
> Turned Mint vector into a 7,1 matrix, so dimensions fit with evolution matrix.
>
> 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=23955&r1=23954&r2=23955&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:44 2014
> @@ -132,7 +132,7 @@
>      # Loop over the time points, back calculating the R2eff values.
>      for i in range(num_points):
>          # Initial magnetisation.
> -        Mint = M0
> +        Mint = M0.reshape(7, 1)
>
>          # This matrix is a propagator that will evolve the magnetization 
> with the matrix R for a delay tcp.
>          Rexpo = matrix_exponential(R*tcp[i])
> @@ -145,7 +145,7 @@
>              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.
> -        Mx = Mint[1] / pA
> +        Mx = Mint[1][0] / pA
>          if Mx <= 0.0 or isNaN(Mx):
>              back_calc[i] = r20a
>          else:
>
>
> _______________________________________________
> relax (http://www.nmr-relax.com)
>
> This is the relax-commits mailing list
> [email protected]
>
> 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

_______________________________________________
relax (http://www.nmr-relax.com)

This is the relax-devel mailing list
[email protected]

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-devel

Reply via email to