Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-xt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
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
ag-ohlberger
dune-community
dune-xt
Commits
be121eb6
Commit
be121eb6
authored
5 years ago
by
Tobias Leibner
Browse files
Options
Downloads
Patches
Plain Diff
[bisect] also add abs_error, fix documentation
parent
fd2b31b7
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
dune/xt/common/bisect.hh
+4
-3
4 additions, 3 deletions
dune/xt/common/bisect.hh
with
4 additions
and
3 deletions
dune/xt/common/bisect.hh
+
4
−
3
View file @
be121eb6
...
...
@@ -22,7 +22,7 @@ namespace Common {
/**
* \brief Finds the largest number x between left and right, where condition(x) is true, but condition(y) is false for
* any y
<
x.
* any y
>
x.
*
* \note Presumes that: if condition(x_1) == condition(x_2) == value,
* then there does not exist a x_1 < y < x_2, s.t. condition(y) == !value;
...
...
@@ -30,7 +30,8 @@ namespace Common {
double
find_largest_by_bisection
(
const
double
&
left
,
const
double
&
right
,
std
::
function
<
bool
(
const
double
&
)
>
condition
,
const
double
rel_error
=
1e-15
)
const
double
rel_error
=
1e-16
,
const
double
abs_error
=
1e-16
)
{
double
ll
=
(
left
<
right
)
?
left
:
right
;
double
rr
=
(
left
<
right
)
?
right
:
left
;
...
...
@@ -38,7 +39,7 @@ double find_largest_by_bisection(const double& left,
return
rr
;
DUNE_THROW_IF
(
!
condition
(
ll
),
Exceptions
::
bisection_error
,
""
);
// no we know that ll is good, rr is bad
while
(
FloatCmp
::
gt
(
rr
,
ll
,
rel_error
))
{
while
(
FloatCmp
::
gt
(
rr
,
ll
,
rel_error
,
abs_error
))
{
const
double
middle
=
0.5
*
(
ll
+
rr
);
if
(
condition
(
middle
))
ll
=
middle
;
...
...
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