Commit 6d1b25f8 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

bug fix

parent 3ad02747
......@@ -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)
......@@ -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)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment