I'm using STM32f407vg
When i was trying to simulate complex structure in signal processing project i found some problems
simply there is a portion of code that causes the problem:
Code: Select all
typedef struct {double r;double i;} Complex;
Complex CPLX(double _r, double _i){
Complex c;
c.r = _r;
c.i = _i;
return c;
}
Complex xAdd(Complex x,Complex y){
return CPLX(x.r + y.r , x.i + y.i);
}
Complex xMul(Complex x,Complex y){
return CPLX(x.r * y.r - x.i * y.i , x.r * y.i + x.i * y.r);
}
void main() {
Complex a,b,sum,mul;
while(1){
a = CPLX(1,0); // 1
b = CPLX(0,1); // i
sum = xAdd(a,b); // => should be : 1 + i
mul = xMul(a,b); // => should be : i
Delay_ms(1000);
}
}