Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
goertzel-nostd
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package 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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stephen D
goertzel-nostd
Commits
c86e0daf
Commit
c86e0daf
authored
9 years ago
by
Matt McPherrin
Browse files
Options
Downloads
Patches
Plain Diff
Add a mag method, for doing one shot magnitude calculation
parent
4b3ae488
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/lib.rs
+5
-1
5 additions, 1 deletion
src/lib.rs
with
5 additions
and
1 deletion
src/lib.rs
+
5
−
1
View file @
c86e0daf
...
...
@@ -37,6 +37,10 @@ impl Parameters {
pub
fn
start
(
self
)
->
Partial
{
Partial
{
params
:
self
,
count
:
0
,
prev
:
0.
,
prevprev
:
0.
}
}
pub
fn
mag
(
self
,
samples
:
&
[
i16
])
->
f32
{
self
.start
()
.add
(
samples
)
.finish_mag
()
}
}
impl
Partial
{
...
...
@@ -84,7 +88,7 @@ fn sine() {
let
mag
=
p
.start
()
.add
(
&
buf
[
..
])
.finish_mag
();
for
testfreq
in
(
0
..
30
)
.map
(|
x
|
(
x
*
100
)
as
f32
)
{
let
p
=
Parameters
::
new
(
testfreq
,
8000
,
8000
);
let
testmag
=
p
.
start
()
.add
(
&
buf
[
..
])
.finish_mag
(
);
let
testmag
=
p
.
mag
(
&
buf
[
..
]
);
println!
(
"{:4}: {:12.3}"
,
testfreq
,
testmag
);
if
(
freq
-
testfreq
)
.abs
()
>
100.
{
println!
(
"{} > 10*{}"
,
mag
,
testmag
);
...
...
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