I'm using an EWISE statement in a procedure and it's not working properly. I'm wondering if anyone has any suggestions.
EWISE AUX1(I) = (2/LAGS * (LAGS-I)) ** 2
AUX1 is a local real vector, dim LAGS-1. When LAGS=2, then AUX1 has just one element, 1. That works fine. If I set LAGS to anything else, like 3 or 4, the vector contains all zeros.
Any ideas why?
Problems with EWISE statement
The problem is that you are doing integer division here:
2/LAGS
Integer division returns an integer result, with any remainder truncated. So, if LAGS = 3, you are getting:
2/3 = 0.66667
which truncates down to zero.
Assuming you want a fractional result, you need to make one or both terms real rather than integer. Easiest way is to add a decimal to the "2". For example:
EWISE AUX1(I) = (2.0/LAGS * (LAGS-I)) ** 2
Tom Maycock
Estima
2/LAGS
Integer division returns an integer result, with any remainder truncated. So, if LAGS = 3, you are getting:
2/3 = 0.66667
which truncates down to zero.
Assuming you want a fractional result, you need to make one or both terms real rather than integer. Easiest way is to add a decimal to the "2". For example:
EWISE AUX1(I) = (2.0/LAGS * (LAGS-I)) ** 2
Tom Maycock
Estima