[cig-commits] [commit] master: py: Remove redundant loop. (ab48b2b)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Mon Jan 12 13:11:39 PST 2015
Repository : https://github.com/geodynamics/specfem1d
On branch : master
Link : https://github.com/geodynamics/specfem1d/compare/9969ec4660bfbd56d30e7cea351276fec0318f59...067b9384a823b64c0f0fe1aff95de89c7d9d5397
>---------------------------------------------------------------
commit ab48b2be7387539d60e92f3de19e33a8bda5b6c9
Author: Elliott Sales de Andrade <esalesde at physics.utoronto.ca>
Date: Mon Jan 12 15:23:58 2015 -0500
py: Remove redundant loop.
Alexis has confirmed to me that the loop is redundant and just setting
m=j is sufficient here.
>---------------------------------------------------------------
ab48b2be7387539d60e92f3de19e33a8bda5b6c9
Python_version/gll.py | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/Python_version/gll.py b/Python_version/gll.py
index cad5b40..fe81357 100644
--- a/Python_version/gll.py
+++ b/Python_version/gll.py
@@ -70,14 +70,11 @@ def lagrange_derivative(ksiGLL):
for m in range(N+1):
if m!=i:
prod1 *= 1/(ksiGLL[i]-ksiGLL[m])
- sum1=0.
- for m in range(N+1):
- prod2=1.
- for k in range(N+1):
- if k!=m and k!=i:
- prod2 *= (ksiGLL[j]-ksiGLL[k])
- sum1 += prod2
- deriv[i,j]=prod1*sum1
+ prod2=1.
+ for k in range(N+1):
+ if k!=j and k!=i:
+ prod2 *= (ksiGLL[j]-ksiGLL[k])
+ deriv[i,j]=prod1*prod2
return deriv
More information about the CIG-COMMITS
mailing list