summaryrefslogtreecommitdiff
path: root/src/c/signalProcessing/zpch2
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/zpch2
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/zpch2')
-rw-r--r--src/c/signalProcessing/zpch2/dzpch2s.c63
-rw-r--r--src/c/signalProcessing/zpch2/int_zpch2.h18
-rw-r--r--src/c/signalProcessing/zpch2/zpch2.h28
3 files changed, 109 insertions, 0 deletions
diff --git a/src/c/signalProcessing/zpch2/dzpch2s.c b/src/c/signalProcessing/zpch2/dzpch2s.c
new file mode 100644
index 0000000..22a46a6
--- /dev/null
+++ b/src/c/signalProcessing/zpch2/dzpch2s.c
@@ -0,0 +1,63 @@
+/* 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 "zpch2.h"
+#include "multiplication.h"
+#include "abs.h"
+#include "division.h"
+#define PI 3.14159265
+double dzpch2s(double N, double A, double omegar,doubleComplex* zeros,doubleComplex* poles)
+{
+ int k,j;
+ double e,xk,realVal,gain;
+ doubleComplex accumulate1,accumulate2,tp1,tp2;
+ accumulate1=DoubleComplex(1,0);
+ accumulate2=DoubleComplex(1,0);
+ int ct=0;
+ for(k=1;k<=N;k++)
+ {
+ if(k!=((N+1)/2))
+ {
+ ct++;
+ double num=PI*(2*k-1);
+ double den=2*N;
+ xk=cos(num/den);
+ double sk=omegar/xk;
+ zeros[k-1]=DoubleComplex(0,sk);
+ tp1=DoubleComplex(0,sk);
+ accumulate1=zmuls(accumulate1,tp1);
+ }
+ }
+ for(j=1;j<=N;j++)
+ {
+ double num=PI*(2*j-1);
+ double den=2*N;
+ double xk1=num/den;
+ double Gamma=pow((A+sqrt(A*A-1)),(1/N));
+ double alpha=-((Gamma-1/Gamma)/2)*sin(xk1);
+ double Beta=((Gamma+1/Gamma)/2)*cos(xk1);
+ double normal=alpha*alpha+Beta*Beta;
+ poles[j-1]=DoubleComplex((omegar*alpha)/normal,(omegar*Beta)/normal);
+ tp2=DoubleComplex((omegar*alpha)/normal,(omegar*Beta)/normal);
+ accumulate2=zmuls(accumulate2,tp2);
+ }
+ double qt;
+ double ra2=zreals(accumulate2);
+ double ra1=zreals(accumulate1);
+ qt=dldivs(ra1,ra2);
+ gain=dabss(qt);
+
+ return gain;
+
+}
+
diff --git a/src/c/signalProcessing/zpch2/int_zpch2.h b/src/c/signalProcessing/zpch2/int_zpch2.h
new file mode 100644
index 0000000..683a761
--- /dev/null
+++ b/src/c/signalProcessing/zpch2/int_zpch2.h
@@ -0,0 +1,18 @@
+/* Copyright (C) 2016 - 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_ZPCH2_H__
+#define __INT_ZPCH2_H__
+
+#define d0d0d0zpch2z2z2(N,A,omegar,zeros,poles) dzpch2s(N,A,omegar,zeros,poles)
+
+#endif /* !INT_ZPCH2_H__! */
diff --git a/src/c/signalProcessing/zpch2/zpch2.h b/src/c/signalProcessing/zpch2/zpch2.h
new file mode 100644
index 0000000..0d191d5
--- /dev/null
+++ b/src/c/signalProcessing/zpch2/zpch2.h
@@ -0,0 +1,28 @@
+/* Copyright (C) 2016 - 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 __ZPCH2_H__
+#define __ZPCH2_H__
+#include "types.h"
+#include "doubleComplex.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void dzpch2s(double N, double A, double omegar,doubleComplex* zeros,doubleComplex* poles);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* __ZPCH2_H__ */