Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-common
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package 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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Core Modules
dune-common
Commits
b8b9bb40
Commit
b8b9bb40
authored
9 years ago
by
Elias Pipping
Browse files
Options
Downloads
Patches
Plain Diff
Fix matrix norm computation with NaN values
parent
a8e32a87
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!15
flyspray/FS#1147: Compute norm of vectors with NaN entries properly
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/common/densematrix.hh
+58
-20
58 additions, 20 deletions
dune/common/densematrix.hh
with
58 additions
and
20 deletions
dune/common/densematrix.hh
+
58
−
20
View file @
b8b9bb40
...
...
@@ -567,31 +567,69 @@ namespace Dune
}
//! infinity norm (row sum norm, how to generalize for blocks?)
typename
FieldTraits
<
value_type
>::
real_type
infinity_norm
()
const
{
if
(
size
()
==
0
)
return
0.0
;
ConstIterator
it
=
begin
();
typename
remove_const
<
typename
FieldTraits
<
value_type
>::
real_type
>::
type
max
=
(
*
it
).
one_norm
();
for
(
it
=
it
+
1
;
it
!=
end
();
++
it
)
max
=
std
::
max
(
max
,
(
*
it
).
one_norm
());
return
max
;
template
<
typename
vt
=
value_type
,
typename
std
::
enable_if
<!
has_nan
<
vt
>
::
value
,
int
>::
type
=
0
>
typename
FieldTraits
<
vt
>::
real_type
infinity_norm
()
const
{
using
real_type
=
typename
FieldTraits
<
vt
>::
real_type
;
using
std
::
max
;
real_type
norm
=
0.0
;
for
(
auto
&&
x
:
*
this
)
{
real_type
const
a
=
x
.
one_norm
();
norm
=
max
(
a
,
norm
);
}
return
norm
;
}
//! simplified infinity norm (uses Manhattan norm for complex values)
typename
FieldTraits
<
value_type
>::
real_type
infinity_norm_real
()
const
{
if
(
size
()
==
0
)
return
0.0
;
template
<
typename
vt
=
value_type
,
typename
std
::
enable_if
<!
has_nan
<
vt
>
::
value
,
int
>::
type
=
0
>
typename
FieldTraits
<
vt
>::
real_type
infinity_norm_real
()
const
{
using
real_type
=
typename
FieldTraits
<
vt
>::
real_type
;
using
std
::
max
;
real_type
norm
=
0.0
;
for
(
auto
&&
x
:
*
this
)
{
real_type
const
a
=
x
.
one_norm_real
();
norm
=
max
(
a
,
norm
);
}
return
norm
;
}
ConstIterator
it
=
begin
();
typename
remove_const
<
typename
FieldTraits
<
value_type
>::
real_type
>::
type
max
=
(
*
it
).
one_norm_real
();
for
(
it
=
it
+
1
;
it
!=
end
();
++
it
)
max
=
std
::
max
(
max
,
(
*
it
).
one_norm_real
());
//! infinity norm (row sum norm, how to generalize for blocks?)
template
<
typename
vt
=
value_type
,
typename
std
::
enable_if
<
has_nan
<
vt
>
::
value
,
int
>::
type
=
0
>
typename
FieldTraits
<
vt
>::
real_type
infinity_norm
()
const
{
using
real_type
=
typename
FieldTraits
<
vt
>::
real_type
;
using
std
::
max
;
real_type
norm
=
0.0
;
real_type
isNaN
=
1.0
;
for
(
auto
&&
x
:
*
this
)
{
real_type
const
a
=
x
.
one_norm
();
norm
=
max
(
a
,
norm
);
isNaN
+=
a
;
}
isNaN
/=
isNaN
;
return
norm
*
isNaN
;
}
return
max
;
//! simplified infinity norm (uses Manhattan norm for complex values)
template
<
typename
vt
=
value_type
,
typename
std
::
enable_if
<
has_nan
<
vt
>
::
value
,
int
>::
type
=
0
>
typename
FieldTraits
<
vt
>::
real_type
infinity_norm_real
()
const
{
using
real_type
=
typename
FieldTraits
<
vt
>::
real_type
;
using
std
::
max
;
real_type
norm
=
0.0
;
real_type
isNaN
=
1.0
;
for
(
auto
&&
x
:
*
this
)
{
real_type
const
a
=
x
.
one_norm_real
();
norm
=
max
(
a
,
norm
);
isNaN
+=
a
;
}
isNaN
/=
isNaN
;
return
norm
*
isNaN
;
}
//===== solve
...
...
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