summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/c/signalProcessing/%k/dmodka.c25
-rw-r--r--src/c/signalProcessing/%sn/dmodsns.c10
-rw-r--r--src/c/signalProcessing/ell1mag/dell1maga.c2
-rw-r--r--src/c/signalProcessing/ell1mag/zell1maga.c11
-rw-r--r--src/c/signalProcessing/ffilt/gffilts.c9
-rw-r--r--src/c/signalProcessing/fsfirlin/dfsfirlina.c2
-rw-r--r--src/c/signalProcessing/sincd/dsincds.c1
-rw-r--r--src/c/signalProcessing/sincd/u8sincds.c5
-rw-r--r--src/c/signalProcessing/zmodsns.c161
-rw-r--r--src/c/signalProcessing/zpbutt/dzpbutts.c1
-rw-r--r--src/c/string/ascii/gasciia.c4
-rw-r--r--src/c/string/includes/ascii.h2
-rw-r--r--src/c/string/strcspn/gstrcspna.c6
13 files changed, 196 insertions, 43 deletions
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<stdio.h>
#include<math.h>
#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;i<sz;i++)
{
if(ptr[i]<0)
@@ -47,10 +57,7 @@ void dmodka(double* inp,int size,double* oup)
c[l]=sqrt(inp[l]);
}
- int x=0;
- //double maxi;
- //maxi=max_calc(c,size);
- //printf("%lf",maxi);
+ int x=0;
while(max_calc(c,size)>eps)
{
@@ -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<size;i++)
{
- s[i]=zmodsns(z[i],m1);
+ s[i]=dmodsns(z[i],m1);
}
double un[size];
int j;
diff --git a/src/c/signalProcessing/ell1mag/zell1maga.c b/src/c/signalProcessing/ell1mag/zell1maga.c
index 6e7a6f9..35b4928 100644
--- a/src/c/signalProcessing/ell1mag/zell1maga.c
+++ b/src/c/signalProcessing/ell1mag/zell1maga.c
@@ -14,6 +14,9 @@
#include "modsn.h"
#include "ell1mag.h"
#include "doubleComplex.h"
+#include "multiplication.h"
+#include "addition.h"
+#include "division.h"
void zell1maga(double eps,double m1,doubleComplex* z,int size,double* oup )
{
@@ -31,9 +34,15 @@ void zell1maga(double eps,double m1,doubleComplex* z,int size,double* oup )
}
doubleComplex v;
int k;
+ double ml;
+ ml=eps*eps;
+ doubleComplex tp1,tp2,tp3;
for(k=0;k<size;k++)
{
- v=un[k]/(un[k]+(eps*eps*s[k]*s[k]));
+ tp1=zmuls(s[k],s[k]);
+ tp2=DoubleComplex(ml,0);
+ tp3=DoubleComplex(un[k],0);
+ v=zrdivs(tp3,zadds(tp3,(zmuls(tp2,tp1))));
oup[k]=zreals(v);
}
}
diff --git a/src/c/signalProcessing/ffilt/gffilts.c b/src/c/signalProcessing/ffilt/gffilts.c
index 538daf3..09876d0 100644
--- a/src/c/signalProcessing/ffilt/gffilts.c
+++ b/src/c/signalProcessing/ffilt/gffilts.c
@@ -80,11 +80,4 @@ void gffilts(char* ft,int size,double N,double fc,double fh,double* oup)
oup[id]=1+oup[id];
}
}
-/*
-int main()
-{
- string s;
- int n;
- double fl,fh;
-}
-*/
+
diff --git a/src/c/signalProcessing/fsfirlin/dfsfirlina.c b/src/c/signalProcessing/fsfirlin/dfsfirlina.c
index d2079f4..e44f464 100644
--- a/src/c/signalProcessing/fsfirlin/dfsfirlina.c
+++ b/src/c/signalProcessing/fsfirlin/dfsfirlina.c
@@ -11,11 +11,9 @@
*/
#include<stdio.h>
-
#include<math.h>
#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<stdio.h>
#include<math.h>
#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<stdio.h>
#include<math.h>
#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<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;
+}
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<stdio.h>
#include<math.h>
#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<size;i++)
{
- *(oup+i)=(int)str[i];
+ *(oup+i)=str[i];
}
}
diff --git a/src/c/string/includes/ascii.h b/src/c/string/includes/ascii.h
index fcf969d..39aeb83 100644
--- a/src/c/string/includes/ascii.h
+++ b/src/c/string/includes/ascii.h
@@ -17,7 +17,7 @@
extern "C" {
#endif
-void gasciia(char* str,int size,int* oup);
+void gasciia(char* str,int size,uint8* oup);
void dasciia(double* inp,int size,char* oup);
#ifdef __cplusplus
diff --git a/src/c/string/strcspn/gstrcspna.c b/src/c/string/strcspn/gstrcspna.c
index b611fff..2c83c72 100644
--- a/src/c/string/strcspn/gstrcspna.c
+++ b/src/c/string/strcspn/gstrcspna.c
@@ -16,11 +16,11 @@ uint8 gstrcspna(char *str1,int size1,char *str2,int size2)
{
int ind,i,j;
- for(i=0;i<=size1;i++)
+ for(i=0;i<=size2;i++)
{
- for(j=0;j<=size2;j++)
+ for(j=0;j<=size1;j++)
{
- if(str2[j]==str1[i])
+ if(str2[i]==str1[j])
{
ind=j;
break;