Skip to content

Implementation of matrix norm for order greater than 2 #10705

Open
@mick-d

Description

@mick-d

When using numpy.linalg.norm with ord different from 2, for example 3, then I expected the norm to be computed according to the documentation, i.e. as sum(abs(x)**ord)**(1./ord)

But instead I got:

ValueError                                Traceback (most recent call last)
<ipython-input-784-3344f4d8d663> in <module>()
----> 1 nnorm((distpdfs_diverg['BC']/n_samples) - np.eye(n_bundles), 3)

/usr/lib/python3.5/site-packages/numpy/linalg/linalg.py in norm(x, ord, axis, keepdims)
   2247             ret = _multi_svd_norm(x, row_axis, col_axis, sum)
   2248         else:
-> 2249             raise ValueError("Invalid norm order for matrices.")
   2250         if keepdims:
   2251             ret_shape = list(x.shape)

ValueError: Invalid norm order for matrices.

Looking at the source code (numpy 1.13, numpy 1.14, and current) it seems it is simply the norm is simply not implemented for ord greater than 2 contrarily to what the doc says. Would that be something difficult to do?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions