summaryrefslogtreecommitdiff
path: root/src/c/signalProcessing/%sn
diff options
context:
space:
mode:
authorsiddhu89902017-06-21 15:46:02 +0530
committersiddhu89902017-06-21 15:46:02 +0530
commit7dd99346700740df9480b1f47221e24afc32371d (patch)
tree41b5094514f9a62d40483a1b6c0481c115220c04 /src/c/signalProcessing/%sn
parentadbc46709966e50b3fed6ff061afff9e59d4b79c (diff)
parent061f07929cc984788154bc296c6cc440ef72a3c6 (diff)
downloadScilab2C_fossee_old-7dd99346700740df9480b1f47221e24afc32371d.tar.gz
Scilab2C_fossee_old-7dd99346700740df9480b1f47221e24afc32371d.tar.bz2
Scilab2C_fossee_old-7dd99346700740df9480b1f47221e24afc32371d.zip
Merged Ankit's work, signal processing and string functions
Diffstat (limited to 'src/c/signalProcessing/%sn')
-rw-r--r--src/c/signalProcessing/%sn/dmodsna.c24
-rw-r--r--src/c/signalProcessing/%sn/dmodsns.c93
-rw-r--r--src/c/signalProcessing/%sn/int_modsn.h18
-rw-r--r--src/c/signalProcessing/%sn/modsn.h27
-rw-r--r--src/c/signalProcessing/%sn/zmodsna.c24
-rw-r--r--src/c/signalProcessing/%sn/zmodsns.c161
6 files changed, 347 insertions, 0 deletions
diff --git a/src/c/signalProcessing/%sn/dmodsna.c b/src/c/signalProcessing/%sn/dmodsna.c
new file mode 100644
index 0000000..7e1e81c
--- /dev/null
+++ b/src/c/signalProcessing/%sn/dmodsna.c
@@ -0,0 +1,24 @@
+/* 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<stdio.h>
+#include<math.h>
+#include "modsn.h"
+
+void dmodsna(double* uu,int size,double emmc,double* sn)
+{
+ int i;
+ for(i=0;i<size;i++)
+ {
+ sn[i]=dmodsns(uu[i],emmc);
+ }
+}
+
diff --git a/src/c/signalProcessing/%sn/dmodsns.c b/src/c/signalProcessing/%sn/dmodsns.c
new file mode 100644
index 0000000..06d0a6f
--- /dev/null
+++ b/src/c/signalProcessing/%sn/dmodsns.c
@@ -0,0 +1,93 @@
+/* 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<stdio.h>
+#include<math.h>
+#define CA 0.0003
+#include "modsn.h"
+double dmodsns(double uu, double emmc)
+{
+ double a,b,c,d,emc,u;
+ double em[14],en[14];
+ int i,ii,l,bo;
+ double sn,cn,dn;
+ emc=1-emmc;
+ u=uu;
+ if(emc)
+ {
+ bo=(emc<0.0);
+ if(bo)
+ {
+ d=1.0-emc;
+ emc/=-1.0/d;
+ u*=(d=sqrt(d));
+ }
+ a=1.0;
+ dn=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;
+ sn=sin(u);
+ cn=cos(u);
+ if(sn)
+ {
+ a=cn/sn;
+ c*=a;
+ for(ii=l;ii>=1;ii--)
+ {
+ b=em[ii];
+ a*=c;
+ c*=dn;
+ dn=(en[ii]+a)/(b+a);
+ a=c/b;
+ }
+ a=1.0/sqrt(c*c+1.0);
+ sn=(sn>=0.0?a:-a);
+ cn=c*(sn);
+ }
+ if(bo)
+ {
+ a=dn;
+ dn=cn;
+ cn=a;
+ sn/=d;
+ }
+ }
+ else
+ {
+ cn=1.0/cosh(u);
+ dn=cn;
+ sn=tanh(u);
+ }
+ return sn;
+}
+/*
+int main()
+{
+ double u,k;
+ u=4;
+ k=0.7;
+ sn(u,k);
+}
+*/
diff --git a/src/c/signalProcessing/%sn/int_modsn.h b/src/c/signalProcessing/%sn/int_modsn.h
new file mode 100644
index 0000000..179fb61
--- /dev/null
+++ b/src/c/signalProcessing/%sn/int_modsn.h
@@ -0,0 +1,18 @@
+/* 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
+ */
+
+#ifndef __INT_MODSN_H__
+#define __INT_MODSN_H__
+
+#define d0d0modsnd0(uu,emmc) dmodsns(uu,emmc)
+
+#endif /* !INT_MODSN_H__! */
diff --git a/src/c/signalProcessing/%sn/modsn.h b/src/c/signalProcessing/%sn/modsn.h
new file mode 100644
index 0000000..c589656
--- /dev/null
+++ b/src/c/signalProcessing/%sn/modsn.h
@@ -0,0 +1,27 @@
+/* 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
+ */
+
+#ifndef __MODSN_H__
+#define __MODSN_H__
+#include "types.h"
+
+#ifdef __cplusplus
+extern "c" {
+#endif
+
+double dmodsns(double uu, double emmc);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* __MODSN_H__ */
diff --git a/src/c/signalProcessing/%sn/zmodsna.c b/src/c/signalProcessing/%sn/zmodsna.c
new file mode 100644
index 0000000..33052a3
--- /dev/null
+++ b/src/c/signalProcessing/%sn/zmodsna.c
@@ -0,0 +1,24 @@
+/* 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<stdio.h>
+#include<math.h>
+#include "modsn.h"
+#include "doubleComplex.h"
+
+void zmodsna(doubleComplex* uu,int size,double emmc,doubleComplex* sn)
+{
+ int i;
+ for(i=0;i<size;i++)
+ {
+ sn[i]=zmodsns(uu[i],emmc);
+ }
+}
diff --git a/src/c/signalProcessing/%sn/zmodsns.c b/src/c/signalProcessing/%sn/zmodsns.c
new file mode 100644
index 0000000..5f35059
--- /dev/null
+++ b/src/c/signalProcessing/%sn/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<stdio.h>
+#include<math.h>
+#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;
+}