Skip to content

bug(itensorlike): linsolve() broken — missing IndexMapping to treetn solver #351

@shinaoka

Description

@shinaoka

Summary

tensor4all_itensorlike::linsolve() is non-functional. All calls fail with index structure mismatch errors.

Root Cause

The high-level linsolve() wrapper calls treetn's square_linsolve() without passing IndexMapping objects. The treetn solver requires these mappings to know how MPO input/output indices correspond to MPS site indices. Without them, the MPO's output indices remain after contraction as new indices that don't match the MPS site indices.

Error Examples

  • Identity operator solve: "Index count mismatch: self has 3 indices, other has 4"
  • Shifted identity: "index structure mismatch between operator output (hx) and input (x)"

Workaround

Use the treetn-level API directly with SquareLinsolveUpdater::with_index_mappings().

Suggested Fix

Either:

  1. Accept IndexMapping in LinsolveOptions and pass it through, or
  2. Auto-infer the mapping from shared DynIndex IDs between MPO and MPS

Also add integration tests for linsolve at the itensorlike level (currently none exist).

Found by

Automated feature test (test-feature-20260327-itensorlike)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions