diff options
author | Ankit Raj | 2017-06-21 11:00:07 +0530 |
---|---|---|
committer | Ankit Raj | 2017-06-21 11:00:07 +0530 |
commit | efd4b2645e3fd3c3cdd7b65501a0e7ae26d03c59 (patch) | |
tree | 65444449ab64db280008c59b08204ee775db26df /src/c/signalProcessing/%k | |
parent | b33afdb2311fbe8aad4c5c614c6098585fe2d279 (diff) | |
download | Scilab2C_fossee_old-efd4b2645e3fd3c3cdd7b65501a0e7ae26d03c59.tar.gz Scilab2C_fossee_old-efd4b2645e3fd3c3cdd7b65501a0e7ae26d03c59.tar.bz2 Scilab2C_fossee_old-efd4b2645e3fd3c3cdd7b65501a0e7ae26d03c59.zip |
Functions added - string related and signal processing
Diffstat (limited to 'src/c/signalProcessing/%k')
-rw-r--r-- | src/c/signalProcessing/%k/dmodka.c | 97 | ||||
-rw-r--r-- | src/c/signalProcessing/%k/int_modk.h | 18 | ||||
-rw-r--r-- | src/c/signalProcessing/%k/modk.h | 29 |
3 files changed, 144 insertions, 0 deletions
diff --git a/src/c/signalProcessing/%k/dmodka.c b/src/c/signalProcessing/%k/dmodka.c new file mode 100644 index 0000000..c0630ec --- /dev/null +++ b/src/c/signalProcessing/%k/dmodka.c @@ -0,0 +1,97 @@ +#include<stdio.h> +#include<math.h> +#include "modk.h" +double max_calc(double* ptr,int sz) +{ + int i=0; + double mx; + if(ptr[0]<0) + { + ptr[0]=-1*ptr[0]; + } + mx=(ptr[0]); + //printf("%lf\n",mx); + for(i=1;i<sz;i++) + { + if(ptr[i]<0) + { + ptr[i]=-1*ptr[i]; + } + if(mx<(ptr[i])) + mx=(ptr[i]); + } + return mx; +} +void dmodka(double* inp,int size,double* oup) +{ + double ones[size],PI=M_PI; + double eps=pow(2,-52); + int i; + for(i=0;i<size;i++) + { + ones[i]=1; + } + double a[size],b[size],c[size],an[size],bn[size],cn[size],kans[size]; + + int j,kk,l,m; + for(j=0;j<size;j++) + { + a[j]=1; + } + for(kk=0;kk<size;kk++) + { + b[kk]=sqrt(ones[kk]-inp[kk]); + } + for(l=0;l<size;l++) + { + c[l]=sqrt(inp[l]); + + } + int x=0; + //double maxi; + //maxi=max_calc(c,size); + //printf("%lf",maxi); + + while(max_calc(c,size)>eps) + { + int q,w,r; + for(q=0;q<size;q++) + { + an[q]=0.5*(a[q]+b[q]); + } + for(w=0;w<size;w++) + { + bn[w]=sqrt(a[w]*b[w]); + } + for(r=0;r<size;r++) + { + cn[r]=0.5*(a[r]-b[r]); + } + int x,y,z; + for(x=0;x<size;x++) + { + a[x]=an[x]; + } + for(y=0;y<size;y++) + { + b[y]=bn[y]; + } + for(z=0;z<size;z++) + { + c[z]=cn[z]; + } + } + int q,w; + for(q=0;q<size;q++) + { + oup[q]=PI*(ones[q]/(2*a[q])); + } + +} +/* +int main() +{ + double m[3]={0.1,0.2,0.3}; + dka(m,3); +} +*/ diff --git a/src/c/signalProcessing/%k/int_modk.h b/src/c/signalProcessing/%k/int_modk.h new file mode 100644 index 0000000..ae09c50 --- /dev/null +++ b/src/c/signalProcessing/%k/int_modk.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_%K_H__ +#define __INT_%K_H__ + +#define d2modkz2(inp,size,oup) dmodka(inp,size,oup) + +#endif /* !INT_%K_H__! */ diff --git a/src/c/signalProcessing/%k/modk.h b/src/c/signalProcessing/%k/modk.h new file mode 100644 index 0000000..6b4a7e0 --- /dev/null +++ b/src/c/signalProcessing/%k/modk.h @@ -0,0 +1,29 @@ +/* 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 __%K_H__ +#define __%K_H__ +#include "types.h" +#include "doubleComplex.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void dmodka(double* inp,int size,doubleComplex* oup); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* __%K_H__ */ + |