Skip to content

Euclidean norm for sparse matrices crashes when calling .norm() or norm(...) #40492

@JosePisco

Description

@JosePisco

Steps To Reproduce

Trying to compute the euclidean norm (default) on a sparse matrix crashes as it has got no SVD attribute.

sage: version()
'SageMath version 10.6, Release Date: 2025-03-31'
sage: P = Permutation([1, 2, 4, 5, 3])
sage: M = 17/23 * P.to_matrix() + -4/23 * P.inverse().to_matrix()
sage: M.norm()
...
AttributeError: 'sage.matrix.matrix_double_sparse.Matrix_double_sparse' object has no attribute 'SVD'

Expected Behavior

We should still be able to compute its norm.

Actual Behavior

When the matrix is created as a sparse matrix, computing the default norm (euclidean) crashes because sparse matrices don't expose a method used when computing the euclidean norm.

Additional Information

No response

Environment

  • OS: Ubuntu 22.04.4 LTS
  • Sage Version: 'SageMath version 10.6, Release Date: 2025-03-31'

Checklist

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.
  • I have read the documentation and troubleshoot guide

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions