Skip to content

RFC: specify expected behavior for matrix_norm and vector_norm when provided an empty array #901

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

Open
jakevdp opened this issue Feb 18, 2025 · 2 comments
Labels
RFC Request for comments. Feature requests and proposed changes.

Comments

@jakevdp
Copy link

jakevdp commented Feb 18, 2025

It would be useful for the specification to state the expected result of an empty norm (related to the discussion in numpy/numpy#28343)

In #232, it was decided that sum and prod of empty arays should return 0 and 1 respectively, as these are the additive and multiplicative identites, and for min and max to leave the behavior explicitly undefined.

If we extend this logic to matrix_norm, it implies that for ord='fro' or ord='nuc', the result for an empty matrix should be 0.0, and for other values of ord the behavior is undefined.

Extending this logic to vector_norm, it implies that for an empty vector the p-norm should be 0.0 for positive p; the correct behavior for negative and infinite p are less clear to me.

@jakevdp jakevdp changed the title Specificatin for empty matrix_norm and vector_norm? Specification for empty matrix_norm and vector_norm? Feb 18, 2025
@carlosgmartin
Copy link

any norm of an empty matrix is zero

Carl de Boor. An empty exercise. ACM Signum Newsletter 25 (4), 2-6, 1990.

@jakevdp
Copy link
Author

jakevdp commented Feb 19, 2025

Related note:

...

Thanks @carlosgmartin – I think that would be appropriate to discuss in another issue.

This issue is about edge-case behavior in currently defined APIs, so we should stick to that.

@kgryte kgryte changed the title Specification for empty matrix_norm and vector_norm? RFC: specify expected behavior for matrix_norm and vector_norm when provided an empty array Apr 3, 2025
@kgryte kgryte added the RFC Request for comments. Feature requests and proposed changes. label Apr 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFC Request for comments. Feature requests and proposed changes.
Projects
None yet
Development

No branches or pull requests

3 participants