[gfortran] Exponentiation by integral exponents
Feng Wang
wf_cs@yahoo.com
Fri Apr 30 02:07:00 GMT 2004
Hi, Tobi, Paul, etc
I missed the discussion because of my poor modem. But I have implemented this
and the patch is under test. IMHO, we have to implement the algorithm described
by Knuth in the FE. BUILT_IN_POW only deals with Real type. How about complex
type? There are also many problems to consider when an integer is raised to an
negative integer. The result is just 0, -1, or 1. So it is not correct to
convert integer to real. I think we should also implement the runtime library
function powi. When a value is raised to an varible integer, we just call the
library function. The value may be of integer type, real type or complex type.
I have done these and in a few days I will give the patch. I didn't port Andy's
implementation. Andy's vertion only deal with exponent under 100 and don't
consider (integer ** negative integer). The main algorithm in my implementation
is from builtins.c and can deal with an arbitrary integer exponent. The
algorithm in powi library function is from libf77.
Feng Wang
--- Tobias_Schlüter <tobias.schlueter@physik.uni-muenchen.de> µÃÃýÃãº> Paul
Brook wrote:
> >>Now I have to find out, how to correctly use the builtin. Simply
> >>replacing "pow" by "__builtin_pow" in trans-decl.c didn't work, the
> >>compiler generates a call to __builtin_pow in the assembly, which is not
> >>what I want.
> >
> >
> > You need to remove gfor_fndecl_math_pow* and create the nodes in
> > gfc_init_builtin_functions, like we do for floor and round.
> ^ more like sin and cos :-)
> > You can then use built_in_decls[BUILT_IN_POW] instead of
> gfor_fndecl_math_pow.
> >
>
> Thanks! The code works now. I'll clean this up, deal with the complex
> case etc, and will submit once I can. I think I'll leave adding a new
> powi builtin to gcc for a follow-up patch, as that could also be applied
> to mainline gcc.
>
> Thanks for the initial pointer, Andrew!
> - Tobi
_________________________________________________________
Do You Yahoo!?
»ÃÃÃTTÃÃ÷¾ç£¬ÃæÃÃ÷£¬Ãô󽱣¡
http://cn.rd.yahoo.com/mail_cn/tag/SIG=1402c0to2/**http%3A%2F%2Fhp.allyes.com%2Flaserjet%2Fgamestory%2Findex.html%3Fjumpid%3Dex_hphqapcn_MongooseLJ1010%2F201073CN407016%2FYahoo
More information about the Fortran
mailing list