Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
OPOSSUM
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
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
phelix
rust
OPOSSUM
Commits
7b88a3d2
Commit
7b88a3d2
authored
1 year ago
by
Udo Eisenbarth
Browse files
Options
Downloads
Patches
Plain Diff
Slightly improve performance of resample function.
parent
95020194
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/spectrum.rs
+5
-8
5 additions, 8 deletions
src/spectrum.rs
with
5 additions
and
8 deletions
src/spectrum.rs
+
5
−
8
View file @
7b88a3d2
...
...
@@ -220,16 +220,15 @@ impl Spectrum {
}
fn
enclosing_interval
(
&
self
,
x_lower
:
f64
,
x_upper
:
f64
)
->
Vec
<
Option
<
usize
>>
{
let
mut
res
=
self
.clone
()
.lambdas
.
into_
iter
()
.iter
()
.enumerate
()
.filter
(|
x
|
x
.1
<
x_upper
&&
x
.1
>
x_lower
)
.filter
(|
x
|
*
x
.1
<
x_upper
&&
*
x
.1
>
x_lower
)
.map
(|
x
|
Some
(
x
.0
))
.collect
::
<
Vec
<
Option
<
usize
>>>
();
if
res
.is_empty
()
{
let
mut
lower_idx
=
self
.
clone
()
.
lambdas
.
into_
iter
()
.position
(|
x
|
x
>=
x_lower
);
let
upper_idx
=
self
.
clone
()
.
lambdas
.
into_
iter
()
.position
(|
x
|
x
>=
x_upper
);
let
mut
lower_idx
=
self
.lambdas
.iter
()
.position
(|
x
|
*
x
>=
x_lower
);
let
upper_idx
=
self
.lambdas
.iter
()
.position
(|
x
|
*
x
>=
x_upper
);
if
let
Some
(
l_i
)
=
lower_idx
{
if
l_i
>
0
&&
self
.lambdas
[
l_i
]
>
x_lower
{
lower_idx
=
Some
(
l_i
-
1
);
...
...
@@ -260,15 +259,13 @@ impl Spectrum {
/// Resample a provided [`Spectrum`] to match the given one.
///
/// This function maps values and wavelengths of a provided spectrum to the structure of self. This function conserves the toal
/// This function maps values and wavelengths of a provided spectrum to the structure of self. This function conserves the to
t
al
/// energy if the the given interval is fully contained in self. This does not necessarily conserve peak widths or positions.
///
/// # Panics
///
/// Panics if ???.
pub
fn
resample
(
&
mut
self
,
spectrum
:
&
Spectrum
)
{
let
_data
=
spectrum
.data
.clone
();
let
_x
=
spectrum
.lambdas
.clone
();
let
max_idx
=
self
.data
.len
()
-
1
;
for
x
in
self
.data
.iter_mut
()
.enumerate
()
.filter
(|
x
|
x
.0
<
max_idx
)
{
let
lower_bound
=
*
self
.lambdas
.get
(
x
.0
)
.unwrap
();
...
...
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