> ## Documentation Index
> Fetch the complete documentation index at: https://docs.haiqu.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# SKQD Helpers

### haiqu.sdk.skqd.get\_orbital\_rotation(norb)

Build the orbital rotation matrix for the SIAM model.

Constructs a unitary matrix C that transforms Hamiltonian tensors from
site basis to momentum basis via `rotate_basis(h1e, h2e, C^dagger)`.

The ground state of the Anderson impurity model is significantly sparser
in momentum basis, making SQD sampling more effective. The rotation:

1. Diagonalizes the bath hopping chain (sites 1..norb-1) to obtain
   momentum eigenstates of the non-interacting bath.
2. Leaves the impurity orbital (site 0) unchanged.
3. Permutes the impurity to the center of the orbital ordering so
   that the on-site interaction sits at index `(norb - 1) // 2`
   in the new basis.

* **Parameters:**
  **norb** (*int*) -- Number of spatial orbitals (impurity + bath sites).
* **Returns:**
  Unitary rotation matrix C, shape (norb, norb). Use as:
  ```default theme={null}
  h1e_mom, h2e_mom = rotate_basis(h1e, h2e, C.T.conj())
  ```
* **Return type:**
  *ndarray*

### haiqu.sdk.skqd.rotate\_basis(h1e, h2e, orbital\_rotation)

Rotate the orbital basis of one- and two-body Hamiltonian tensors.

Applies the unitary transformation:

```default theme={null}
h1e'[A,B]       = sum_{a,b} U[A,a] * h1e[a,b] * U*[B,b]
h2e'[A,B,C,D]   = sum_{a,b,c,d} U[A,a] * U*[B,b] * U[C,c] * U*[D,d] * h2e[a,b,c,d]
```

where U = `orbital_rotation` and U\* is its complex conjugate.

* **Parameters:**
  * **h1e** (*ndarray*) -- One-body tensor, shape (norb, norb).
  * **h2e** (*ndarray*) -- Two-body tensor, shape (norb, norb, norb, norb).
  * **orbital\_rotation** (*ndarray*) -- Unitary matrix U, shape (norb, norb).
* **Returns:**
  (h1e\_rotated, h2e\_rotated) in the new basis.
* **Return type:**
  tuple\[*ndarray*, *ndarray*]

### *class* haiqu.sdk.skqd.SKQDOptions(\*, samples\_per\_batch=100, num\_batches=5, max\_iterations=15, symmetrize\_spin=True, configuration\_recovery=False, seed=None)

Options for SQD postprocessing (server-side diagonalization).

These parameters control the classical SQD algorithm, not circuit
generation. Circuit parameters (krylov\_dim, dt) are passed directly
to the circuit builder functions.

* **Parameters:**
  * **samples\_per\_batch** (*int*) -- Number of bitstring samples per SQD batch.
  * **num\_batches** (*int*) -- Number of subsampling batches for SQD.
  * **max\_iterations** (*int*) -- Maximum number of SQD self-consistent iterations.
  * **symmetrize\_spin** (*bool*) -- Whether to enforce spin symmetry in SQD.
  * **configuration\_recovery** (*bool*) -- Whether to apply configuration recovery to
    refine noisy bitstrings using orbital occupancy information. See
    [Configuration recovery](configuration_recovery.md) for what this does
    and when to use it.
  * **seed** (*int* *|* *None*) -- Random seed for reproducibility.
