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
32c9360e
Commit
32c9360e
authored
4 years ago
by
René Fritze
Committed by
René Fritze
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[functions.inverse] simplify helper
parent
7982f374
No related branches found
No related tags found
1 merge request
!31
Sfinae and stuff
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/xt/functions/inverse.hh
+7
-29
7 additions, 29 deletions
dune/xt/functions/inverse.hh
with
7 additions
and
29 deletions
dune/xt/functions/inverse.hh
+
7
−
29
View file @
32c9360e
...
...
@@ -40,34 +40,18 @@ public:
using
DomainType
=
Dune
::
FieldVector
<
double
,
d
>
;
using
RangeReturnType
=
typename
RangeTypeSelector
<
R
,
r
,
rC
>::
return_type
;
template
<
size_t
r_
=
r
,
size_t
rC_
=
rC
,
bool
anything
=
true
>
struct
dim_switch
{
static
const
constexpr
bool
available
=
false
;
};
public:
static
const
constexpr
bool
available
=
(
FunctionType
::
rC
==
FunctionType
::
r
);
template
<
bool
anything
>
struct
dim_switch
<
1
,
1
,
anything
>
static
RangeReturnType
compute
(
const
FunctionType
&
func
,
const
DomainType
&
xx
,
const
XT
::
Common
::
Parameter
&
param
)
{
static
const
constexpr
bool
available
=
true
;
static
RangeReturnType
compute
(
const
FunctionType
&
func
,
const
DomainType
&
xx
,
const
XT
::
Common
::
Parameter
&
param
)
{
if
constexpr
(
FunctionType
::
rC
==
1
&&
FunctionType
::
r
==
1
)
{
auto
value_to_invert
=
func
.
evaluate
(
xx
,
param
);
DUNE_THROW_IF
(
XT
::
Common
::
FloatCmp
::
eq
(
value_to_invert
,
0.
),
Exceptions
::
wrong_input_given
,
"Scalar function value was not invertible!
\n\n
value_to_invert = "
<<
value_to_invert
);
return
1.
/
value_to_invert
;
}
};
template
<
size_t
r_
,
bool
anything
>
struct
dim_switch
<
r_
,
r_
,
anything
>
{
static
const
constexpr
bool
available
=
true
;
static
RangeReturnType
compute
(
const
FunctionType
&
func
,
const
DomainType
&
xx
,
const
XT
::
Common
::
Parameter
&
param
)
{
}
else
if
constexpr
(
available
)
{
auto
matrix_to_invert
=
func
.
evaluate
(
xx
,
param
);
RangeReturnType
inverse_matrix
;
try
{
...
...
@@ -78,15 +62,9 @@ public:
<<
matrix_to_invert
<<
"
\n\n
This was the original error: "
<<
ee
.
what
());
}
return
inverse_matrix
;
}
else
{
static_assert
(
false
,
"compute not available"
);
}
};
public
:
static
const
constexpr
bool
available
=
dim_switch
<>::
available
;
static
RangeReturnType
compute
(
const
FunctionType
&
func
,
const
DomainType
&
xx
,
const
XT
::
Common
::
Parameter
&
param
)
{
return
dim_switch
<>::
compute
(
func
,
xx
,
param
);
}
};
// class InverseFunctionHelper
...
...
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