Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
On Thursday, 7th July from 1 to 3 pm there will be a maintenance with a short downtime of GitLab.
Open sidebar
ift
NIFTy
Commits
3517e77d
Commit
3517e77d
authored
Jul 23, 2018
by
Reimar H Leike
Browse files
added .sum() and .size method to MultiFields
parent
2ef525d5
Changes
1
Hide whitespace changes
Inline
Side-by-side
nifty5/multi/multi_field.py
View file @
3517e77d
...
...
@@ -147,6 +147,36 @@ class MultiField(object):
"""
return
np
.
sqrt
(
np
.
abs
(
self
.
vdot
(
x
=
self
)))
def
sum
(
self
):
""" Computes the sum all field values.
Returns
-------
norm : float
The sum of the field values.
"""
result
=
0.0
for
v
in
self
.
_val
:
if
isinstance
(
v
,
Field
):
#not using += here in case of complex numbers
result
=
result
+
v
.
sum
()
return
result
@
property
def
size
(
self
):
""" Computes the overall degrees of freedom.
Returns
-------
size : int
The sum of the size of the individual fields
"""
result
=
0
for
k
in
self
.
keys
():
result
+=
self
.
_domain
[
k
].
size
return
result
def
squared_norm
(
self
):
""" Computes the square of the L2-norm of the field values.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment