Skip to content

Performance: pseudo_inverse_stacked has significant bottlenecks with large matrices #122

Description

@wilczman

Problem

The pseudo_inverse_stacked() function in cedalion has two major performance bottlenecks that cause significant slowdowns when working with large sensitivity matrices:

  1. Duplicate matrix multiplication: Lines 37-38 compute AAt = Adot.values @ Adot.values.T twice
  2. Inefficient eigenvalue calculation: Uses full eigendecomposition np.linalg.eig() when only the largest eigenvalue is needed

Current Code Location

src/cedalion/imagereco/solver.py -> pseudo_inverse_stacked() around lines 37-38 and eigenvalue computation

Proposed Solution

  1. Remove the duplicate AAt computation
  2. Replace np.linalg.eig(AAt)[0][0].real with np.linalg.norm(AAt, ord=2) for largest eigenvalue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions