From 008026f5162bf79e75565548c1bbe5ca3a8fc248 Mon Sep 17 00:00:00 2001
From: Samo Penic <samo.penic@fe.uni-lj.si>
Date: Thu, 07 Jun 2012 19:19:09 +0000
Subject: [PATCH] Added missing automake files

---
 src/sh.c |   21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/src/sh.c b/src/sh.c
index 7cbb04f..cfab468 100644
--- a/src/sh.c
+++ b/src/sh.c
@@ -9,11 +9,12 @@
     ts_uint j,i;
     ts_spharm *sph=(ts_spharm *)malloc(sizeof(ts_spharm));
 
+    
     /* lets initialize Ylm for each vertex. */
     sph->Ylmi=(ts_double ***)calloc(l,sizeof(ts_double **));
-    for(i=0;i<vlist->n;i++){
-            sph->Ylmi[i]=(ts_double **)calloc(2*l+1,sizeof(ts_double *));
-            for(j=0;j<l;j++){
+    for(i=0;i<l;i++){
+            sph->Ylmi[i]=(ts_double **)calloc(2*i+1,sizeof(ts_double *));
+            for(j=0;j<(2*i+1);j++){
                 sph->Ylmi[i][j]=(ts_double *)calloc(vlist->n,sizeof(ts_double));
             }
     }
@@ -30,10 +31,12 @@
     for(j=0;j<l;j++){
         sph->co[j]=(ts_double *)calloc(2*j+1,sizeof(ts_double));
     }
-   
-    /* Calculate coefficients that will remain constant during all the simulation */ 
-    precomputeShCoeff(sph);
 
+    sph->l=l;   
+
+    /* Calculate coefficients that will remain constant during all the simulation */ 
+   precomputeShCoeff(sph);
+    
     return sph;
 }
 
@@ -50,7 +53,7 @@
         if(sph->Ylmi!=NULL) {
             for(i=0;i<sph->l;i++){
                 if(sph->Ylmi[i]!=NULL){
-                    for(j=0;j<sph->l*2+1;j++){
+                    for(j=0;j<i*2+1;j++){
                         if(sph->Ylmi[i][j]!=NULL) free (sph->Ylmi[i][j]);
                     }
                     free(sph->Ylmi[i]);
@@ -122,9 +125,9 @@
     for(i=0;i<sph->l;i++){
         al=i+1;
         sph->co[i][i+1]=sqrt((2.0*al+1.0)/2.0/M_PI);
-        for(j=0;j<al;j++){
+        for(j=0;j<i;j++){
             am=j+1;
-            sph->co[i][i+1+j]=co[i][i+j]*sqrt(1.0/(al-am+1)/(al+am));
+            sph->co[i][i+1+j]=co[i][i+j]*sqrt(1.0/(al-am+1.0)/(al+am));
             sph->co[i][i+1-j]=co[i][i+1+j];
         }
         co[i][2*i]=co[i][2*i]*sqrt(1.0/(2.0*al));

--
Gitblit v1.9.3