summaryrefslogtreecommitdiff
path: root/2.3-1/src/c/signalProcessing/fsfirlin/dfsfirlina.c
blob: e44f464e91ecf11a6aed7cd1b2d341487fc37194 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/* 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 "sincd.h"
#include "fsfirlin.h"

void dfsfirlina(double* hd,int size,double flag,double* hst)
{
	int n1=size,n;
	if( n1%2==0)
	{
	n=2*n1;
	}
	else
	{
	n=2*n1+1;
	}
	double scd[8*n+1];
	//STRAT SINCD
	double npt=4*n;
	int sz=4*n;
	double PI=M_PI;
	double pas=PI/npt;
	double om[sz+1];
	int i;
	for(i=0;i<=sz;i++)
	{
	om[i]=i*pas;
	}
	double eps=pow(-1,(n-1));
	double s1[sz+1],s2[sz+1];
	double s[2*(sz)+1];
	double sr[2*(sz)+1];
	if(flag==1)
	{
	int j,k;
	for(j=0;j<=4*n;j++)
	{
	s1[j]=sin(n*om[j]);
	s2[j]=sin(om[j]);
	}
	s1[0]=n;
	s2[0]=1;
	s1[sz]=n*eps;
	s2[sz]=1;
	
	for(k=0;k<=4*n;k++)
	{
	s[k]=s1[k]/s2[k];
	}
	
	int x;
	for(x=0;x<=4*n;x++)
	{
	    scd[sz-x]=s[x];
	}
	int l;
	for(l=4*n+1;l<=8*n;l++)
	{
	scd[l]=s[l-(sz)];
	}
	int m;
	for(m=0;m<=8*n;m++)
	{
	scd[m]=scd[m]/n;
	}
	}
	else
	{
	int a;
	for(a=0;a<=4*n;a++)
	{
	om[a]=om[a]-(PI/(2*n));
	}
	int j,k;
	for(j=0;j<=4*n;j++)
	{
	s1[j]=sin(n*om[j]);
	s2[j]=sin(om[j]);
	}
	s1[2]=n;
	s2[2]=1;
	for(k=0;k<=4*n;k++)
	{
	s[k]=s1[k]/s2[k];
	}
	int m;
	for(m=0;m<=4*n;m++)
	{
	scd[m]=(eps*s[m])/n;
	}
	int l;
	for(l=4*n+1;l<=8*n;l++)
	{
	scd[l]=s[l-(sz)]/n;
	}
	}
	//END SINCD
	int ii;
	for(ii=4*n;ii<=6*n;ii++)
	{
	hst[ii-(4*n)]=hd[0]*scd[ii];
	}
	
	int epsi;
	epsi=pow(-1,n-1);
	int jj;
	for(jj=1;jj<=(n1-1);jj++)
	{
	double tp1[2*n+1];
	double tp2[2*n+1];
	int k,l;
	for(k=(-4*jj+4*n);k<=(-4*jj+6*n);k++)
	{
	tp1[k-(-4*jj+4*n)]=hd[jj]*scd[k];
	}
	
	for(l=(4*jj);l<=(4*jj+2*n);l++)
	{
	tp2[l-(4*jj)]=hd[jj]*(epsi*scd[l]);
	}
	int m;
	for(m=0;m<=2*n;m++)
	{
	hst[m]=hst[m]+(tp1[m]+tp2[m]);
	}
	
	}
		
	
}