-
Notifications
You must be signed in to change notification settings - Fork 1
/
fdt.cpp
50 lines (44 loc) · 990 Bytes
/
fdt.cpp
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
#include "fdt.h"
double FDT::ProductoEscalar(double* arr1, double* arr2, int N)
{
double res=0;
for(int i=0;i<N;i++)
res+=arr1[i]*arr2[i];
return res;
}
void FDT::Desplazar()
{
for(int i=gradoNum;i>0;i--)
xk[i]=xk[i-1];
for(int i=gradoDen;i>0;i--)
yk[i]=yk[i-1];
}
FDT::FDT(double* numerador,double* denominador,int nNum,int nDen)
{
gradoNum=nNum-1;
gradoDen=nDen-1;
coefNum=new double[nNum];
yk=new double[nNum];
coefDen=new double[nDen];
xk=new double[nDen];
for(int i=0;i<nNum;i++){
coefNum[i]=numerador[i];
yk[i]=0;
}
for(int i=0;i<nDen;i++){
coefDen[i]=denominador[i];
xk[i]=0;
}
}
FDT::~FDT(){
delete [] coefNum;
delete [] coefDen;
delete [] xk;
delete [] yk;
}
double FDT::Calc(double in){
Desplazar();
xk[0]=in;
yk[0]=(ProductoEscalar(coefNum,xk,gradoNum+1)-ProductoEscalar(coefDen+1,yk+1,gradoDen))/coefDen[0];
return yk[0];
}