[PATCH] libm/complex: add clog10, clog10f

Craig Howland howland@LGSInnovations.com
Thu Feb 18 21:55:00 GMT 2016



On 02/18/2016 11:53 AM, Yaakov Selkowitz wrote:
> ...
> diff --git a/newlib/libm/complex/clog10f.c b/newlib/libm/complex/clog10f.c
> new file mode 100644
> index 0000000..98cf606
> --- /dev/null
> +++ b/newlib/libm/complex/clog10f.c
> @@ -0,0 +1,15 @@
> +#include <complex.h>
> +#include <math.h>
> +
> +float complex
> +clog10f(float complex z)
> +{
> +	float complex w;
> +	float p, rr;
> +
> +	rr = cabsf(z);
> +	p = log10f(rr);
> +	rr = atan2f(cimagf(z), crealf(z)) * M_IVLN10;
> +	w = p + rr * I;
> +	return w;
> +}
> ...
The rr calculation needs a cast for the constant, otherwise it will use double 
for the multiply:

	rr = atan2f(cimagf(z), crealf(z)) * (float) M_IVLN10;

Craig



More information about the Newlib mailing list