mirror of
https://github.com/xiph/opus.git
synced 2025-05-31 07:37:42 +00:00
Improve exp2's precision to 20-24 bits.
The exp2 function was approximated using lolremez, achieving an accuracy of less than 2*10^-7 within the range of 0 to 1. Signed-off-by: Jean-Marc Valin <jeanmarcv@google.com>
This commit is contained in:
parent
7fa23b4ed0
commit
255f013035
2 changed files with 38 additions and 9 deletions
|
@ -1,6 +1,7 @@
|
|||
/* Copyright (c) 2008-2011 Xiph.Org Foundation, Mozilla Corporation,
|
||||
Gregory Maxwell
|
||||
Written by Jean-Marc Valin, Gregory Maxwell, and Timothy B. Terriberry */
|
||||
Written by Jean-Marc Valin, Gregory Maxwell, Timothy B. Terriberry,
|
||||
and Yunho Huh */
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
|
@ -170,21 +171,32 @@ void testlog2(void)
|
|||
void testexp2(void)
|
||||
{
|
||||
float x;
|
||||
float error_threshold = 2.3e-07;
|
||||
float max_error = 0;
|
||||
for (x=-11.0;x<24.0;x+=0.0007f)
|
||||
{
|
||||
float error = fabs(x-(1.442695040888963387*log(celt_exp2(x))));
|
||||
if (error>0.0002)
|
||||
if (max_error < error)
|
||||
{
|
||||
fprintf (stderr, "celt_exp2 failed: fabs(x-(1.442695040888963387*log(celt_exp2(x))))>0.0005 (x = %f, error = %f)\n", x,error);
|
||||
max_error = error;
|
||||
}
|
||||
|
||||
if (error > error_threshold)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"celt_exp2 failed: "
|
||||
"fabs(x-(1.442695040888963387*log(celt_exp2(x))))>%15.25e "
|
||||
"(x = %f, error = %15.25e)\n", error_threshold, x, error);
|
||||
ret = 1;
|
||||
}
|
||||
}
|
||||
fprintf (stdout, "celt_exp2 max_error: %15.25e\n", max_error);
|
||||
}
|
||||
|
||||
void testexp2log2(void)
|
||||
{
|
||||
float x;
|
||||
float error_threshold = 5.0e-04;
|
||||
float error_threshold = 2.0e-06;
|
||||
float max_error = 0;
|
||||
for (x=-11.0;x<24.0;x+=0.0007f)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue