Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dof_array.flat_norm is CL-specific #219

Closed
kaushikcfd opened this issue Jun 12, 2021 · 3 comments · Fixed by #222
Closed

dof_array.flat_norm is CL-specific #219

kaushikcfd opened this issue Jun 12, 2021 · 3 comments · Fixed by #222

Comments

@kaushikcfd
Copy link
Collaborator

cf.

import pyopencl.array as cl
assert isinstance(ary, cl.Array)

@kaushikcfd
Copy link
Collaborator Author

kaushikcfd commented Jun 12, 2021

Why does flat_norm flatten a group array before computing the norm?

In [2]: a = np.random.rand(3, 3)

In [3]: np.linalg.norm(a)
Out[3]: 1.899203808354709

In [4]: np.linalg.norm(a.reshape(-1))
Out[4]: 1.899203808354709

@kaushikcfd
Copy link
Collaborator Author

kaushikcfd commented Jun 12, 2021

Why does flat_norm flatten a group array before computing the norm?

Oops forgot my 450 here. Feel free to ignore this. Numpy's default norm being Frobenius norm, didn't help :P.

@inducer
Copy link
Owner

inducer commented Jun 12, 2021

To be fair, I think numpy defaults to Frobenius, which is equivalent to a flattened 2-norm for 2D arrays. For (say 3D) tensor product elements, the shape will likely be (nelements, Np, Np, Np), which would just be an error in numpy, making the flatten necessary after all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants