From 1dc99d862fe3178a3a6e72e2c1338000545ec859 Mon Sep 17 00:00:00 2001 From: Ankitr19 Date: Fri, 7 Jul 2017 12:47:56 +0530 Subject: Demos and RPi compiler compatibility --- src/c/signalProcessing/%k/dmodka.c | 25 +++-- src/c/signalProcessing/%sn/dmodsns.c | 10 +- src/c/signalProcessing/ell1mag/dell1maga.c | 2 +- src/c/signalProcessing/ell1mag/zell1maga.c | 11 +- src/c/signalProcessing/ffilt/gffilts.c | 9 +- src/c/signalProcessing/fsfirlin/dfsfirlina.c | 2 - src/c/signalProcessing/sincd/dsincds.c | 1 - src/c/signalProcessing/sincd/u8sincds.c | 5 +- src/c/signalProcessing/zmodsns.c | 161 +++++++++++++++++++++++++++ src/c/signalProcessing/zpbutt/dzpbutts.c | 1 + src/c/string/ascii/gasciia.c | 4 +- src/c/string/includes/ascii.h | 2 +- src/c/string/strcspn/gstrcspna.c | 6 +- 13 files changed, 196 insertions(+), 43 deletions(-) create mode 100644 src/c/signalProcessing/zmodsns.c (limited to 'src') diff --git a/src/c/signalProcessing/%k/dmodka.c b/src/c/signalProcessing/%k/dmodka.c index c0630ec..8368cb6 100644 --- a/src/c/signalProcessing/%k/dmodka.c +++ b/src/c/signalProcessing/%k/dmodka.c @@ -1,3 +1,14 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Ankit Raj + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in + */ #include #include #include "modk.h" @@ -10,7 +21,6 @@ double max_calc(double* ptr,int sz) ptr[0]=-1*ptr[0]; } mx=(ptr[0]); - //printf("%lf\n",mx); for(i=1;ieps) { @@ -88,10 +95,4 @@ void dmodka(double* inp,int size,double* oup) } } -/* -int main() -{ - double m[3]={0.1,0.2,0.3}; - dka(m,3); -} -*/ + diff --git a/src/c/signalProcessing/%sn/dmodsns.c b/src/c/signalProcessing/%sn/dmodsns.c index 06d0a6f..aae16c1 100644 --- a/src/c/signalProcessing/%sn/dmodsns.c +++ b/src/c/signalProcessing/%sn/dmodsns.c @@ -82,12 +82,4 @@ double dmodsns(double uu, double emmc) } return sn; } -/* -int main() -{ - double u,k; - u=4; - k=0.7; - sn(u,k); -} -*/ + diff --git a/src/c/signalProcessing/ell1mag/dell1maga.c b/src/c/signalProcessing/ell1mag/dell1maga.c index 9af0c8e..58ef303 100644 --- a/src/c/signalProcessing/ell1mag/dell1maga.c +++ b/src/c/signalProcessing/ell1mag/dell1maga.c @@ -21,7 +21,7 @@ void dell1maga(double eps,double m1,double* z,int size,double* oup ) int i; for(i=0;i - #include #include "sincd.h" #include "fsfirlin.h" -//#define PI 3.14159265358979 void dfsfirlina(double* hd,int size,double flag,double* hst) { diff --git a/src/c/signalProcessing/sincd/dsincds.c b/src/c/signalProcessing/sincd/dsincds.c index 1475d8d..c9f2f81 100644 --- a/src/c/signalProcessing/sincd/dsincds.c +++ b/src/c/signalProcessing/sincd/dsincds.c @@ -13,7 +13,6 @@ #include #include #include "sincd.h" -//#define PI 3.14159265358979 void dsincds(double n,double flg,double* oup) { double npt=4*n; diff --git a/src/c/signalProcessing/sincd/u8sincds.c b/src/c/signalProcessing/sincd/u8sincds.c index d03f48a..ff0a2ac 100644 --- a/src/c/signalProcessing/sincd/u8sincds.c +++ b/src/c/signalProcessing/sincd/u8sincds.c @@ -13,12 +13,11 @@ #include #include #include "sincd.h" -#define PI 3.14159265358979 void u8sincds(int n,int flg,double* oup) { double npt=4*n; int sz=4*n; - double pas=PI/npt; + double pas=M_PI/npt; double om[sz+1]; int i; //om[0]=0; @@ -69,7 +68,7 @@ void u8sincds(int n,int flg,double* oup) int a; for(a=0;a<=4*n;a++) { - om[a]=om[a]-(PI/(2*n)); + om[a]=om[a]-(M_PI/(2*n)); } int j,k; for(j=0;j<=4*n;j++) diff --git a/src/c/signalProcessing/zmodsns.c b/src/c/signalProcessing/zmodsns.c new file mode 100644 index 0000000..5f35059 --- /dev/null +++ b/src/c/signalProcessing/zmodsns.c @@ -0,0 +1,161 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Ankit Raj + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in + Reference:- Abramowitz, Milton and Stegun, Irene A + Handbook of Mathematical Functions, Dover, 1965 + Chapter 16 (Sections 16.4, 16.13 and 16.15) + Link for FORTRAN code:-http://www.aip.de/groups/soe/local/numres/bookfpdf/f6-11.pdf +*/ + +#include +#include +#include "modsn.h" +#include "doubleComplex.h" +#define CA 0.0003 + +doubleComplex zmodsns(doubleComplex uu,double emmc) +{ + 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; + ans=DoubleComplex(snir,snii); + return ans; +} diff --git a/src/c/signalProcessing/zpbutt/dzpbutts.c b/src/c/signalProcessing/zpbutt/dzpbutts.c index 33f22af..7b9fe9b 100644 --- a/src/c/signalProcessing/zpbutt/dzpbutts.c +++ b/src/c/signalProcessing/zpbutt/dzpbutts.c @@ -12,6 +12,7 @@ #include #include #include "zpbutt.h" +#include "doubleComplex.h" #define PI 3.14159265 double dzpbutts(double n,double fl,doubleComplex* out) { diff --git a/src/c/string/ascii/gasciia.c b/src/c/string/ascii/gasciia.c index ec11d6e..5fe95e0 100644 --- a/src/c/string/ascii/gasciia.c +++ b/src/c/string/ascii/gasciia.c @@ -14,12 +14,12 @@ into its ascii equivalent. */ #include "ascii.h" -void gasciia(char *str,int size,int* oup) +void gasciia(char *str,int size,uint8* oup) { int i; for(i=0;i