Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
NIFTy
Commits
6d1b25f8
Commit
6d1b25f8
authored
Sep 03, 2018
by
Martin Reinecke
Browse files
bug fix
parent
3ad02747
Changes
2
Hide whitespace changes
Inline
Side-by-side
nifty5/data_objects/distributed_do.py
View file @
6d1b25f8
...
...
@@ -559,7 +559,8 @@ def absmax(arr):
if
arr
.
_data
.
size
==
0
:
tmp
=
np
.
array
(
0
,
dtype
=
arr
.
_data
.
dtype
)
else
:
tmp
=
np
.
asarray
(
np
.
linalg
.
norm
(
arr
.
_data
,
ord
=
np
.
inf
))
tmp
=
np
.
asarray
(
np
.
linalg
.
norm
(
np
.
atleast_1d
(
arr
.
_data
).
reshape
(
-
1
),
ord
=
np
.
inf
))
res
=
np
.
empty_like
(
tmp
)
_comm
.
Allreduce
(
tmp
,
res
,
MPI
.
MAX
)
return
res
[()]
...
...
@@ -568,7 +569,8 @@ def absmax(arr):
def
norm
(
arr
,
ord
=
2
):
if
ord
==
np
.
inf
:
return
absmax
(
arr
)
tmp
=
np
.
asarray
(
np
.
linalg
.
norm
(
np
.
atleast_1d
(
arr
.
_data
),
ord
=
ord
)
**
ord
)
tmp
=
np
.
asarray
(
np
.
linalg
.
norm
(
np
.
atleast_1d
(
arr
.
_data
).
reshape
(
-
1
),
ord
=
ord
)
**
ord
)
res
=
np
.
empty_like
(
tmp
)
_comm
.
Allreduce
(
tmp
,
res
,
MPI
.
SUM
)
return
res
[()]
**
(
1.
/
ord
)
nifty5/data_objects/numpy_do.py
View file @
6d1b25f8
...
...
@@ -144,8 +144,8 @@ def ensure_default_distributed(arr):
def
absmax
(
arr
):
return
np
.
linalg
.
norm
(
arr
,
ord
=
np
.
inf
)
return
np
.
linalg
.
norm
(
np
.
atleast_1d
(
arr
).
rehape
(
-
1
)
,
ord
=
np
.
inf
)
def
norm
(
arr
,
ord
=
2
):
return
np
.
linalg
.
norm
(
np
.
atleast_1d
(
arr
),
ord
=
ord
)
return
np
.
linalg
.
norm
(
np
.
atleast_1d
(
arr
)
.
reshape
(
-
1
)
,
ord
=
ord
)
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment