[CLN-list] Types in cl_R

Isidro Cachadiña Gutiérrez icacha at unex.es
Thu Nov 18 22:44:10 CET 2004


El Jueves, 18 de Noviembre de 2004 13:13, Bruno Haible escribió:
> Isidro Cachadiña Gutiérrez wrote:
> > cl_R x,y,z;
> >
> > z=expt(x,y);
> >
> > I have problems with the prototypes defined in <real.h> that causes that
> > expt cannot be used in this way.
>
> If x is negative, the result can be a complex number. If you know a priori
> that the result will be real, you can use a checked cast:
>
>    z = As(cl_R)(expt(x,y));

>
> > I also can define this function as:
> >
> > cln::cl_R expt(cln::cl_R x, cln::cl_R y)
> > {
> >   return exp(x*ln(y));
> > }
>
> Actually this is the other way around: exp(x*ln(y)) is y^x, not x^y.
>
Correct.   Must be exp(y*ln(x)).

> By using 'ln' here, not the more general 'log', you have asserted that the
> base is > 0. No wonder you don't need a cast here.

Yes, of course.  I'm insterested on real functions depending on real 
arguments. 

Now, I have the same problem with functions like cos, acos, etc.  which 
depends on complex arguments, for example

cl_R acos (cl_R x ) is not defined you have to do something like

 realpart(acos(complex(x,0)))

or are there anything quicker and dirty ?.

> Bruno
>
>
> _______________________________________________
> CLN-list mailing list
> CLN-list at thep.physik.uni-mainz.de
> http://thep.physik.uni-mainz.de/mailman/listinfo/cln-list

-- 
***************************************************************************
*                    Dr. Isidro Cachadiña Gutiérrez                       * 
*                        Departamento de Física                           * 
*                         Facultad de Ciencias                            *
*                      Universidad de Extremadura                         *
*                        06071  Badajoz ( SPAIN )                         * 
*                         email: icacha at unex.es                           * 
*    Teléfono: +34 924 289 300 Ext. 6826     Fax: +34 924 289 651	  *
***************************************************************************
* Usuario Linux: 8569							  *
* Para clave pública GnuPG: http://onsager.unex.es/firma.pub.asc          *
***************************************************************************
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.cebix.net/pipermail/cln-list/attachments/20041118/5857b4f0/attachment.pgp


More information about the CLN-list mailing list