Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
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
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
mlz
BornAgain
Commits
5c191a14
Commit
5c191a14
authored
2 years ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
+ outcommented code that is not fully equivalent to lower_bound & upper_bound
parent
d779a025
No related branches found
No related tags found
1 merge request
!1024
make slicing readable, ctd
Pipeline
#74872
passed
2 years ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Resample/Processed/ParticleSpans.cpp
+15
-7
15 additions, 7 deletions
Resample/Processed/ParticleSpans.cpp
with
15 additions
and
7 deletions
Resample/Processed/ParticleSpans.cpp
+
15
−
7
View file @
5c191a14
...
@@ -38,22 +38,30 @@ std::vector<double> bottomLayerCoordinates(const MultiLayer& sample)
...
@@ -38,22 +38,30 @@ std::vector<double> bottomLayerCoordinates(const MultiLayer& sample)
return
result
;
return
result
;
}
}
size_t
iLayerTop
(
double
top
,
const
std
::
vector
<
double
>
ZBottoms
)
size_t
iLayerTop
(
double
top
,
const
std
::
vector
<
double
>
&
ZBottoms
)
{
{
if
(
top
<=
ZBottoms
.
back
())
if
(
top
<=
ZBottoms
.
back
())
return
ZBottoms
.
size
();
return
ZBottoms
.
size
();
for
(
size_t
i
=
0
;
i
<=
ZBottoms
.
size
();
++
i
)
/* ???
for (size_t i = 0; i < ZBottoms.size(); ++i)
if (ZBottoms.at(ZBottoms.size()-1-i) < top)
if (ZBottoms.at(ZBottoms.size()-1-i) < top)
return
ZBottoms
.
size
()
-
1
-
i
;
return ZBottoms.size()-i;
ASSERT
(
0
);
return 0;
// auto index_above = std::lower_bound(ZBottoms.rbegin(), ZBottoms.rend(), top);
/* */
// return static_cast<size_t>(ZBottoms.rend() - index_above);
auto
index_above
=
std
::
lower_bound
(
ZBottoms
.
rbegin
(),
ZBottoms
.
rend
(),
top
);
return
static_cast
<
size_t
>
(
ZBottoms
.
rend
()
-
index_above
);
}
}
size_t
iLayerBottom
(
double
bottom
,
const
std
::
vector
<
double
>
ZBottoms
)
size_t
iLayerBottom
(
double
bottom
,
const
std
::
vector
<
double
>
&
ZBottoms
)
{
{
if
(
bottom
<
ZBottoms
.
back
())
if
(
bottom
<
ZBottoms
.
back
())
return
ZBottoms
.
size
();
return
ZBottoms
.
size
();
/* ???
for (size_t i = 0; i < ZBottoms.size(); ++i)
if (ZBottoms.at(ZBottoms.size()-1-i) > bottom)
return ZBottoms.size()-i;
return 0;
/* */
auto
index_below
=
std
::
upper_bound
(
ZBottoms
.
rbegin
(),
ZBottoms
.
rend
(),
bottom
);
auto
index_below
=
std
::
upper_bound
(
ZBottoms
.
rbegin
(),
ZBottoms
.
rend
(),
bottom
);
return
static_cast
<
size_t
>
(
ZBottoms
.
rend
()
-
index_below
);
return
static_cast
<
size_t
>
(
ZBottoms
.
rend
()
-
index_below
);
}
}
...
...
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