summaryrefslogtreecommitdiff
path: root/2.3-1/src/c/signalProcessing/%sn
diff options
context:
space:
mode:
authorAnkitr192017-07-04 15:26:35 +0530
committerAnkitr192017-07-04 15:26:35 +0530
commit5cfbe7196dd381f1e3f49f5673ce5c9291748364 (patch)
tree47fba72e042c8218e42d0a638a663b6897487163 /2.3-1/src/c/signalProcessing/%sn
parent6e4535ef3a2c3ec3a4c857673a43938fd04cba80 (diff)
downloadScilab2C-5cfbe7196dd381f1e3f49f5673ce5c9291748364.tar.gz
Scilab2C-5cfbe7196dd381f1e3f49f5673ce5c9291748364.tar.bz2
Scilab2C-5cfbe7196dd381f1e3f49f5673ce5c9291748364.zip
New function and rpi issues resolved
Diffstat (limited to '2.3-1/src/c/signalProcessing/%sn')
-rw-r--r--2.3-1/src/c/signalProcessing/%sn/zmodsna.c143
1 files changed, 142 insertions, 1 deletions
diff --git a/2.3-1/src/c/signalProcessing/%sn/zmodsna.c b/2.3-1/src/c/signalProcessing/%sn/zmodsna.c
index 33052a32..85bc0c16 100644
--- a/2.3-1/src/c/signalProcessing/%sn/zmodsna.c
+++ b/2.3-1/src/c/signalProcessing/%sn/zmodsna.c
@@ -13,12 +13,153 @@
#include<math.h>
#include "modsn.h"
#include "doubleComplex.h"
+#define CA 0.0003
+
+
+doubleComplex zmodsnsproto(doubleComplex uu,double emmc,doubleComplex* sni)
+{
+ doubleComplex ans;
+ double uur,uui;
+ uur=zreals(uu);
+ uui=zimags(uu);
+ double sr,cr,dr;
+ //Performing Elliptic Function operation for the real values
+ double a1,b1,c1,d1,emc1,u1;
+ double em1[14],en1[14];
+ int i1,ii1,l1,bo1;
+ emc1=1-emmc;
+ u1=uur;
+ if(emc1)
+ {
+ bo1=(emc1<0.0);
+ if(bo1)
+ {
+ d1=1.0-emc1;
+ emc1/=-1.0/d1;
+ u1*=(d1=sqrt(d1));
+ }
+ a1=1.0;
+ dr=1.0;
+ for(i1=1;i1<=13;i1++)
+ {
+ l1=i1;
+ em1[i1]=a1;
+ en1[i1]=(emc1=sqrt(emc1));
+ c1=0.5*(a1+emc1);
+ if(fabs(a1-emc1)<=CA*a1)break;
+ emc1*=a1;
+ a1=c1;
+ }
+ u1*=c1;
+ sr=sin(u1);
+ cr=cos(u1);
+ if(sr)
+ {
+ a1=cr/sr;
+ c1*=a1;
+ for(ii1=l1;ii1>=1;ii1--)
+ {
+ b1=em1[ii1];
+ a1*=c1;
+ c1*=dr;
+ dr=(en1[ii1]+a1)/(b1+a1);
+ a1=c1/b1;
+ }
+ a1=1.0/sqrt(c1*c1+1.0);
+ sr=(sr>=0.0?a1:-a1);
+ cr=c1*(sr);
+ }
+ if(bo1)
+ {
+ a1=dr;
+ dr=cr;
+ cr=a1;
+ sr/=d1;
+ }
+ }
+ else
+ {
+ cr=1.0/cosh(u1);
+ dr=cr;
+ sr=tanh(u1);
+ }
+ ////////////////////////////////////////////////////////////////
+ double si,ci,di;
+ //Performing Elleptic Function operation for the imaginary values
+ double a,b,c,d,emc,u;
+ double em[14],en[14];
+ int i,ii,l,bo;
+ //double s1,c1,d1;
+ emc=emmc;
+ u=uui;
+ if(emc)
+ {
+ bo=(emc<0.0);
+ if(bo)
+ {
+ d=1.0-emc;
+ emc/=-1.0/d;
+ u*=(d=sqrt(d));
+ }
+ a=1.0;
+ di=1.0;
+ for(i=1;i<=13;i++)
+ {
+ l=i;
+ em[i]=a;
+ en[i]=(emc=sqrt(emc));
+ c=0.5*(a+emc);
+ if(fabs(a-emc)<=CA*a)break;
+ emc*=a;
+ a=c;
+ }
+ u*=c;
+ si=sin(u);
+ ci=cos(u);
+ if(si)
+ {
+ a=ci/si;
+ c*=a;
+ for(ii=l;ii>=1;ii--)
+ {
+ b=em[ii];
+ a*=c;
+ c*=di;
+ di=(en[ii]+a)/(b+a);
+ a=c/b;
+ }
+ a=1.0/sqrt(c*c+1.0);
+ si=(si>=0.0?a:-a);
+ ci=c*(si);
+ }
+ if(bo)
+ {
+ a=di;
+ di=ci;
+ ci=a;
+ si/=d;
+ }
+ }
+ else
+ {
+ ci=1.0/cosh(u);
+ di=ci;
+ si=tanh(u);
+ }
+ /////////////////////////////////////////////////////////
+ double delta;
+ delta=ci*ci + emmc*sr*sr*si*si;
+ double snir,snii;
+ snir=(sr*di)/delta;
+ snii=(cr*dr*si*ci)/delta;
+ *sni=DoubleComplex(snir,snii);
+}
void zmodsna(doubleComplex* uu,int size,double emmc,doubleComplex* sn)
{
int i;
for(i=0;i<size;i++)
{
- sn[i]=zmodsns(uu[i],emmc);
+ zmodsnsproto(uu[i],emmc,&sn[i]);
}
}