array-api icon indicating copy to clipboard operation
array-api copied to clipboard

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

Open jakevdp opened this issue 9 months ago • 2 comments

It would be useful for the specification to state the expected result of an empty norm (related to the discussion in https://github.com/numpy/numpy/pull/28343)

In https://github.com/data-apis/array-api/issues/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 avatar Feb 18 '25 21:02 jakevdp

any norm of an empty matrix is zero

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

carlosgmartin avatar Feb 19 '25 18:02 carlosgmartin

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.

jakevdp avatar Feb 19 '25 18:02 jakevdp