Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Opus
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marek Pikuła
Opus
Commits
e9d7842c
Unverified
Commit
e9d7842c
authored
9 months ago
by
Jean-Marc Valin
Browse files
Options
Downloads
Patches
Plain Diff
More accurate fixed-point sqrt() approximation
parent
6f4f3e89
No related branches found
Branches containing commit
No related tags found
1 merge request
!1
Draft: Add RISC-V RVV implementation
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
celt/mathops.c
+6
-3
6 additions, 3 deletions
celt/mathops.c
with
6 additions
and
3 deletions
celt/mathops.c
+
6
−
3
View file @
e9d7842c
...
...
@@ -126,7 +126,10 @@ opus_val32 celt_sqrt(opus_val32 x)
int
k
;
opus_val16
n
;
opus_val32
rt
;
static
const
opus_val16
C
[
5
]
=
{
23175
,
11561
,
-
3011
,
1699
,
-
664
};
/* These coeffs are optimized in fixed-point to minimize both RMS and max error
of sqrt(x) over .25<x<1 without exceeding 32767.
The RMS error is 3.4e-5 and the max is 8.2e-5. */
static
const
opus_val16
C
[
6
]
=
{
23171
,
11574
,
-
2901
,
1592
,
-
1002
,
336
};
if
(
x
==
0
)
return
0
;
else
if
(
x
>=
1073741824
)
...
...
@@ -134,8 +137,8 @@ opus_val32 celt_sqrt(opus_val32 x)
k
=
(
celt_ilog2
(
x
)
>>
1
)
-
7
;
x
=
VSHR32
(
x
,
2
*
k
);
n
=
x
-
32768
;
rt
=
ADD
16
(
C
[
0
],
MULT16_16_Q15
(
n
,
ADD16
(
C
[
1
],
MULT16_16_Q15
(
n
,
ADD16
(
C
[
2
],
MULT16_16_Q15
(
n
,
ADD16
(
C
[
3
],
MULT16_16_Q15
(
n
,
(
C
[
4
]
)))))))));
rt
=
ADD
32
(
C
[
0
],
MULT16_16_Q15
(
n
,
ADD16
(
C
[
1
],
MULT16_16_Q15
(
n
,
ADD16
(
C
[
2
],
MULT16_16_Q15
(
n
,
ADD16
(
C
[
3
],
MULT16_16_Q15
(
n
,
ADD16
(
C
[
4
],
MULT16_16_Q15
(
n
,
(
C
[
5
]))
)))))))));
rt
=
VSHR32
(
rt
,
7
-
k
);
return
rt
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment