This bug took me a while. On some sample I ran into infinite loop in the d()
function of the DTW the classifier. This recursive function stops if
if( distanceMatrix[m][n] < 0 )
The problem I discovered was when the calculated distance was exactly 0. As every
returned distance is negated the compiler seemed to treat the value as "-0". This is
probably an architecture and/or compiler dependent bug ( I'm running my code on
arm android ) but when the line of code mentioned above was executed with "-0" as
an argument it did not stopped.
I've fixed the problem by calling the following function before returning any distance
I just didn't investigate any further as I solved my problem with the first fix and did not
study the DTW algorithm enough to be sure of the best solution.
Hi there,
This bug took me a while. On some sample I ran into infinite loop in the d() function of the DTW the classifier. This recursive function stops if
if( distanceMatrix[m][n] < 0 )
The problem I discovered was when the calculated distance was exactly 0. As every returned distance is negated the compiler seemed to treat the value as "-0". This is probably an architecture and/or compiler dependent bug ( I'm running my code on arm android ) but when the line of code mentioned above was executed with "-0" as an argument it did not stopped.
I've fixed the problem by calling the following function before returning any distance
Float avoidMinusZero(Float z) { if(z == 0) return 0.0001; return z; }
Another fix could also be:
if( distanceMatrix[m][n] <= 0 )
I just didn't investigate any further as I solved my problem with the first fix and did not study the DTW algorithm enough to be sure of the best solution.