Pages: 1  3 4 ... 10
 11   on: December 17, 2019, 10:32:46 am Started by Lu?s T. - Last post by Lu?s T. Thanks Rene and Henry,Yesterday my colleague Jos� Virtuoso found a post in Stack Overflow discussing the theme: https://stackoverflow.com/questions/26860574/pow-implementation-in-cmath-and-efficient-replacementThey refer to the same algorithm and also point for an old post with a really deep discussion about efficient implementations of integer based power function: https://stackoverflow.com/questions/101439/the-most-efficient-way-to-implement-an-integer-based-power-function-powint-intIn the meanwhile we'll use your myExp() function!

 12   on: December 17, 2019, 10:04:34 am Started by Lu?s T. - Last post by Rene S. s/ a mail Henry / a mail from Henri /s/ provision / precision /

 13   on: December 17, 2019, 10:02:03 am Started by Lu?s T. - Last post by Rene S. Hello, I got this morning a mail Henri (thanks again).See this url: https://en.wikipedia.org/wiki/Exponentiation_by_squaringThe 4gl operator ** uses integer exponents. This fit's exactly to the problem of computation of large positive integer powers of a number.I've adapted exp_by_squaring_iterative to this function:Code`FUNCTION myExp(x, n)    DEFINE x DECIMAL(32)    DEFINE n INT    DEFINE y DECIMAL(32)     IF x IS NULL OR n IS NULL THEN        RETURN NULL    END IF    IF n < 0 THEN        LET x = 1 / x        LET n = -n    END IF    IF n = 0 THEN        RETURN 1    END IF    LET y = 1    WHILE n > 1        IF (n MOD 2) == 0 THEN            LET x = x * x            LET n = n / 2        ELSE            LET y = x * y            LET x = x * x            LET n = (n - 1) / 2        END IF    END WHILE    RETURN x * yEND FUNCTION`The function is fast and uses a provision of 32.The internal implementation of ** should be adapted as soon as possible

 14   on: December 17, 2019, 08:29:34 am Started by Huy H. - Last post by Rene S. Hello Reuben,Yes, I did.OTH: why adding extra code (setActionActive here and there) if on action infield exists? On action infield has been introduced for exactly this reason: simplify the 4gl code. The runtime controls the activation of actions. If (hypothetically) the attribute clause would be supported for an on action infield then we end in the dilemma: the programmer must repeat all attributes for each action with the same name. This is the opposite of simple.

 15   on: December 17, 2019, 04:43:47 am Started by Huy H. - Last post by Reuben B. Rene,Did you consider the case of a one-off action where it is preferred to define all you need to with the ON ACTION, and therefore no need to touch a .4ad or .per.  In that case I think ...Code`ON ACTION foo INFIELD field1 ATTRIBUTES(TEXT="...", IMAGE="...") `would be preferred toCode`BEFORE INPUT    CALL DIALOG.setActionActive("foo", FALSE)BEFORE FIELD field1    CALL DIALOG.setActionActive("foo", TRUE)AFTER FIELD field1    CALL DIALOG.setActionActive("foo", FALSE) ON ACTION foo ATTRIBUTES(TEXT="...", IMAGE="...")`Reuben

 16   on: December 16, 2019, 04:37:21 pm Started by Lu?s T. - Last post by Rene S. Opps. Yes, this helps a lot! Please wait for more details.

 17   on: December 16, 2019, 04:21:05 pm Started by Lu?s T. - Last post by Lu?s T. Hello Rene,The expoents, in the situation we analysed, are allways negative and run from 0 to -1460. This happens when we call IRR (Internar Return on Investment), using Newton method. We need to actualize each cash-flows of a loan to the number of days from the initial date of the loan. As we are calculating this in a dayly base, and the operation have 4 years duration, it makes around  1460 day for the last flow. In the Newton method we do the calculation several times until we find the right rate. That's why the performance of ** is so relevant.Hope this helpsLuis

 18   on: December 16, 2019, 03:54:42 pm Started by Lu?s T. - Last post by Rene S. Hello Luis,for my curiosity/better understanding: what values of the exponent do you use?Please give an example reproducing the performance factor 100 comparing the operator ** with your c-function. I can't reproduce this with my values.I made a quick test, comparing the performance with Informix c4gl. When using huge exponents (>16) then Informix is faster. If the exponent is less than 16 then Genero is faster.

 19   on: December 16, 2019, 02:54:56 pm Started by Lu?s T. - Last post by Lu?s T. Thanks for the answer Rene.The problem is that, if I call pow(), which is the same than calling the C function we defined, i will loose precision.We detected the inefficiencies of ** when we migrated our application to Genero. At that moment we substituted ** to the C implementation but we went into a situation where our application didn't work as it worked in Informix 4GL. When we analysed the issue we come to the conclusion the reason was loss of precision. When we rollback to the ** operator, we solved the problem.I have the idea that the Informix 4GL implementation of ** is quicker than the Genero's one. Don't you have that idea?Luis

 20   on: December 16, 2019, 02:25:47 pm Started by Lu?s T. - Last post by Rene S. The operator ** calls a decimal implementation of the function power. Notice: the exponent is an int. Code`-- read     a ** b -- as    xxx(a, b)-- where xxx is the    FUNCTION xxx(x DECIMAL, y INT) RETURNS DECIAMAL`Decimal functions are usually slow compared with the same function using float or double parameters.Compare the performance of decimal functions with the performance of float or double function before integrating the math coprocessor x87 into the CPU. In those days (before 80486, launched April 1996) those function were implemented by software. Don't use the operator **.Use util.Math.pow(x FLOAT, y FLOAT) returning FLOATRene

Pages: 1  3 4 ... 10