Bill Allombert on Tue, 12 May 2015 15:29:25 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: incorrect type in gpow(0,n) (t_VEC)


On Tue, May 12, 2015 at 02:32:05PM +0200, Dirk Laurie wrote:
> 2015-02-12 7:33 GMT+02:00 Kevin Acres <research@research-systems.com>:
> The reason is that floating-point a^b is in effect computed
> as exp(log(a)*b). log(0) => bang!

It wwould be so nice if that was the reason for this bug, but unfortunately:
? 0^2.
%1 = 0

Now, the justification for all of this, (barring the bugs):
Traditionally, transcendental GP functions (including ^) operates component by
component on vectors and matrices, so for example:

? sin([1,2,3])
%1 = [0.84147098480789650665250232163029899962,0.90929742682568169539601986591174484270,0.14112000805986722210074480280811027985]

Nowadays, it is cleaner to use apply:
? apply(sin,[1,2,3])
%2 = [0.84147098480789650665250232163029899962,0.90929742682568169539601986591174484270,0.14112000805986722210074480280811027985]

Cheers,
Bill