From: Rainer S. <rai...@gm...> - 2014-08-09 11:54:28
|
To work around a problem with truncated power series, I added special handling for the abs operator, as applied to domain elements (procedure !:abs in alg/dmodeop.red). Previously, abs applied to a domain element d would return either d or -d, depending on whether the domain minusp function returned NIL or T. This doesn't work for non-constant domain elements like truncated power series, these are not positive or negative (and consequently minusp returns nil in all cases). Actually, it doesn't even work for the simple complex domain modes gi (gaussian integers) or cr (complex rounded); therefore we had this ugly piece of code in alg/simp.red for computing the absolute value of a domain element: symbolic procedure mkabsfd u; if null get('i,'idvalfn) then absf u ./ 1 else (simpexpt list(prepsq nrm,'(quotient 1 2)) where nrm = addsq(multsq(car us,car us), multsq(cdr us,cdr us)) where us = splitcomplex u); My update introduces an optional abs function for a domain mode. If it is missing, the code in procedure !:abs falls back to the previous logic of using the minusp function. The tps package is currently the only place where the new abs function is defined for a domain mode. The gi and cr domain modes would benefit as well; ultimately the procedure above could simply be symbolic procedure mkabsfd u; if null u then nil else if atom u then if minusp u then -u else u else !:abs u; Rainer |