Home > Back-end >  Why release VS2015 mode calculation results more accurate than the debug? How to achieve consistent
Why release VS2015 mode calculation results more accurate than the debug? How to achieve consistent

Time:11-18

I was writing a kalman filter for initial alignment of inertial navigation program, there are a large number of matrix floating-point calculations, the release mode of convergence, repeated the experiment result is also stable precision, but in the debug mode will gradually spread, the result error is very big, is this why??
Current problems locating in the measurement update section of the kalman filter, this part involves the division, matrix are stored in two dimensional array, and this matter?
How to make the debug mode has become like the release?

CodePudding user response:

https://stackoverflow.com/questions/141752/float-values-behaving-differently-across-the-release-and-debug-builds

https://docs.microsoft.com/en-us/cpp/build/reference/fp-specify-floating-point-behavior? Redirectedfrom=MSDN& View=v - 2019

Try can refer to these two articles (sorry I for a long time used vs, conditions did not build environment validation), said the main two points: (1) the compiler optimization level try to set up (2) the same floating point/fp option is set,

CodePudding user response:

Thank you very much, but I have set up or not, my wrong code here
Void CKalman: : MeasUpdate (double fading=1.0)
{
Ek=Zk - (Hk * Xk);
Pk Py0=Hk * * (Hk) ~;
for(int i=0; i{
Hi=Hk. Chooserc (' R ', I); Select the ith row//
Pk Pxz=* (~ Hi);
Double Pzz=(* Pxz (Hi) (0)) + (fairly Rk (I, I));
ASSERT (Pzz!=0);
Kk=Pxz * (1.0/Pzz);
Xk=Xk + Kk * ((Zk) (I) - (* Xk (Hi) (0)));
Pk=Pk - Kk * * Hi Pk.
}

Beta=beta/(beta + b);
If (fading> 1.0) Pk=Pk * fading;
}
This is the measurement update, which involves the matrix elements are double

CodePudding user response:

reference navigation laboratory dedicated account on the second floor response:
thank you very much, but I set up or not, I the wrong code here
Void CKalman: : MeasUpdate (double fading=1.0)
{
Ek=Zk - (Hk * Xk);
Pk Py0=Hk * * (Hk) ~;
for(int i=0; I{
Hi=Hk. Chooserc (' R ', I); Select the ith row//
Pk Pxz=* (~ Hi);
Double Pzz=(* Pxz (Hi) (0)) + (fairly Rk (I, I));
ASSERT (Pzz!=0);
Kk=Pxz * (1.0/Pzz);
Xk=Xk + Kk * ((Zk) (I) - (* Xk (Hi) (0)));
Pk=Pk - Kk * * Hi Pk.
}

Beta=beta/(beta + b);
If (fading> 1.0) Pk=Pk * fading;
}
This is measurement update, which involves the matrix elements are double

Is there is something wrong in my calculation order?

CodePudding user response:

reference navigation laboratory dedicated account reply: 3/f
Quote: refer to the second floor navigation laboratory dedicated account response:
thank you very much, but I set up or not, I the wrong code here
Void CKalman: : MeasUpdate (double fading=1.0)
{
Ek=Zk - (Hk * Xk);
Pk Py0=Hk * * (Hk) ~;
for(int i=0; i{
Hi=Hk. Chooserc (' R ', I); Select the ith row//
Pk Pxz=* (~ Hi);
Double Pzz=(* Pxz (Hi) (0)) + (fairly Rk (I, I));
ASSERT (Pzz!=0);
Kk=Pxz * (1.0/Pzz);
Xk=Xk + Kk * ((Zk) (I) - (* Xk (Hi) (0)));
Pk=Pk - Kk * * Hi Pk.
}

Beta=beta/(beta + b);
If (fading> 1.0) Pk=Pk * fading;
}
This is measurement update, which involves the matrix elements are double

Is there is something wrong in my calculation order?


Just found out that under the two words
Pk=Pk - Kk * * Hi Pk.
Pk=(I) - Kk * Hi * Pk.//I for the unit matrix
Arguably are equivalent, in release mode calculation result is completely consistent, but actually in the debug mode is different, and far worse, why?

CodePudding user response:

Involving the scientific computing code, had better use Intel c + + compiler, the floating point optimization is better, and precision will be higher, if higher accuracy requirement, also can use Intel DFP, decimal floating-point library

CodePudding user response:

ASSERT (Pzz!=0);
=====================
This code is wrong, for double is not compared to 0, 0.0000000001111 look up the code,

CodePudding user response:

You can set the release can also debug, from the debug,

CodePudding user response:

refer to 6th floor yshuise response:
ASSERT (Pzz!=0);
=====================
This code is wrong, for double is not compared to 0, 0.0000000001111 look up relevant code,

Thank you very much, it really shouldn't write, but still didn't solve the problem of my code checked many times, now doubt that the problem of overloaded operator *, matrix LianCheng cause problems? Check the written under multiplication
  • Related