qlinks.builders package#
Submodules#
qlinks.builders.optimized_sparse module#
- class qlinks.builders.optimized_sparse.OptimizedSparseBuildStats(n_basis, n_terms, n_raw_actions, n_kept_actions, n_missing_actions, nnz, n_scratch_arrays)[source]#
Bases:
objectCounters collected by
OptimizedSparseHamiltonianBuilder.- __init__(n_basis, n_terms, n_raw_actions, n_kept_actions, n_missing_actions, nnz, n_scratch_arrays)#
- class qlinks.builders.optimized_sparse.OptimizedSparseBuildResult(matrix, stats)[source]#
Bases:
objectOptimized sparse matrix together with build statistics.
- matrix#
Built sparse matrix.
- Type:
Any
- stats#
Counters describing the optimized build.
- stats: OptimizedSparseBuildStats#
- __init__(matrix, stats)#
- class qlinks.builders.optimized_sparse.OptimizedSparseHamiltonianBuilder(dtype=<class 'numpy.complex128'>, on_missing='skip', drop_zero_atol=0.0, backend='scipy')[source]#
Bases:
objectSparse builder for update-style local operators.
Operators return compact local updates rather than full output configurations. The builder owns a reusable scratch configuration and inserts
H[row, col] += coefficientafter applying each update to the current column configuration.- dtype#
Matrix dtype.
- Type:
type[Any] | numpy.dtype[Any] | numpy._typing._dtype_like._SupportsDType[numpy.dtype[Any]] | tuple[Any, Any] | list[Any] | numpy._typing._dtype_like._DTypeDict | str | None
- on_missing#
Policy for actions outside the basis.
- Type:
Literal[‘skip’, ‘raise’]
- backend#
Sparse backend name or backend object.
- Type:
Literal[‘scipy’, ‘cupy’, ‘auto’] | qlinks.backends.sparse.SparseBackend
- dtype: type[Any] | dtype[Any] | _SupportsDType[dtype[Any]] | tuple[Any, Any] | list[Any] | _DTypeDict | str | None#
- backend: Literal['scipy', 'cupy', 'auto'] | SparseBackend#
- __init__(dtype=<class 'numpy.complex128'>, on_missing='skip', drop_zero_atol=0.0, backend='scipy')#
- qlinks.builders.optimized_sparse.build_optimized_sparse_hamiltonian(basis, operators, *, dtype=<class 'numpy.complex128'>, on_missing='skip', drop_zero_atol=0.0, backend='scipy')[source]#
Build a sparse Hamiltonian using update-style operators.
- Parameters:
basis (Basis) – Basis that fixes the matrix row/column order.
operators (Sequence[LocalUpdateOperator | DiagonalLocalOperator]) – Operators supporting
diagonal_valueorapply_update.dtype (type[Any] | dtype[Any] | _SupportsDType[dtype[Any]] | tuple[Any, Any] | list[Any] | _DTypeDict | str | None) – Matrix dtype.
on_missing (Literal['skip', 'raise']) – Policy for actions outside the basis.
drop_zero_atol (float) – Absolute threshold for dropping small coefficients.
backend (Literal['scipy', 'cupy', 'auto'] | ~qlinks.backends.sparse.SparseBackend) – Sparse backend name or backend object.
- Returns:
Sparse Hamiltonian matrix.
- Return type:
qlinks.builders.sparse module#
- class qlinks.builders.sparse.SparseBuildStats(n_basis, n_terms, n_raw_actions, n_kept_actions, n_missing_actions, nnz)[source]#
Bases:
objectCounters collected while building a sparse matrix.
- __init__(n_basis, n_terms, n_raw_actions, n_kept_actions, n_missing_actions, nnz)#
- class qlinks.builders.sparse.SparseBuildResult(matrix, stats)[source]#
Bases:
objectSparse matrix together with build statistics.
- matrix#
Built sparse matrix.
- Type:
Any
- stats#
Counters describing the build.
- stats: SparseBuildStats#
- __init__(matrix, stats)#
- class qlinks.builders.sparse.SparseHamiltonianBuilder(dtype=<class 'numpy.complex128'>, on_missing='skip', combine_duplicates=True, drop_zero_atol=0.0, backend='scipy')[source]#
Bases:
objectGeneric sparse builder for configuration-space local operators.
The builder applies each operator to each basis configuration and inserts the resulting matrix element
H[row, col]. It is the most general builder and works with anyLocalOperator, at the cost of allocating full target configurations for non-diagonal actions.- dtype#
Matrix dtype.
- Type:
type[Any] | numpy.dtype[Any] | numpy._typing._dtype_like._SupportsDType[numpy.dtype[Any]] | tuple[Any, Any] | list[Any] | numpy._typing._dtype_like._DTypeDict | str | None
- on_missing#
Policy for actions outside the basis.
"skip"drops them;"raise"turns them into aKeyError.- Type:
Literal[‘skip’, ‘raise’]
- combine_duplicates#
Whether to combine multiple actions from the same column to the same target before insertion.
- Type:
- backend#
Sparse backend name or backend object.
- Type:
Literal[‘scipy’, ‘cupy’, ‘auto’] | qlinks.backends.sparse.SparseBackend
- dtype: type[Any] | dtype[Any] | _SupportsDType[dtype[Any]] | tuple[Any, Any] | list[Any] | _DTypeDict | str | None#
- backend: Literal['scipy', 'cupy', 'auto'] | SparseBackend#
- __init__(dtype=<class 'numpy.complex128'>, on_missing='skip', combine_duplicates=True, drop_zero_atol=0.0, backend='scipy')#
- qlinks.builders.sparse.build_sparse_hamiltonian(basis, operators, *, dtype=<class 'numpy.complex128'>, on_missing='skip', combine_duplicates=True, drop_zero_atol=0.0, backend='scipy')[source]#
Build a sparse Hamiltonian from local operators.
- Parameters:
basis (Basis) – Basis that fixes the matrix row/column order.
operators (Sequence[LocalOperator]) – Local operators to sum.
dtype (type[Any] | dtype[Any] | _SupportsDType[dtype[Any]] | tuple[Any, Any] | list[Any] | _DTypeDict | str | None) – Matrix dtype.
on_missing (Literal['skip', 'raise']) – Policy for actions outside the basis.
combine_duplicates (bool) – Whether to combine duplicate column actions before inserting them.
drop_zero_atol (float) – Absolute threshold for dropping small coefficients.
backend (Literal['scipy', 'cupy', 'auto'] | ~qlinks.backends.sparse.SparseBackend) – Sparse backend name or backend object.
- Returns:
Sparse Hamiltonian matrix.
- Return type:
Module contents#
- class qlinks.builders.OptimizedSparseBuildResult(matrix, stats)[source]#
Bases:
objectOptimized sparse matrix together with build statistics.
- matrix#
Built sparse matrix.
- Type:
Any
- stats#
Counters describing the optimized build.
- stats: OptimizedSparseBuildStats#
- __init__(matrix, stats)#
- class qlinks.builders.OptimizedSparseBuildStats(n_basis, n_terms, n_raw_actions, n_kept_actions, n_missing_actions, nnz, n_scratch_arrays)[source]#
Bases:
objectCounters collected by
OptimizedSparseHamiltonianBuilder.- __init__(n_basis, n_terms, n_raw_actions, n_kept_actions, n_missing_actions, nnz, n_scratch_arrays)#
- class qlinks.builders.OptimizedSparseHamiltonianBuilder(dtype=<class 'numpy.complex128'>, on_missing='skip', drop_zero_atol=0.0, backend='scipy')[source]#
Bases:
objectSparse builder for update-style local operators.
Operators return compact local updates rather than full output configurations. The builder owns a reusable scratch configuration and inserts
H[row, col] += coefficientafter applying each update to the current column configuration.- dtype#
Matrix dtype.
- Type:
type[Any] | numpy.dtype[Any] | numpy._typing._dtype_like._SupportsDType[numpy.dtype[Any]] | tuple[Any, Any] | list[Any] | numpy._typing._dtype_like._DTypeDict | str | None
- on_missing#
Policy for actions outside the basis.
- Type:
Literal[‘skip’, ‘raise’]
- backend#
Sparse backend name or backend object.
- Type:
Literal[‘scipy’, ‘cupy’, ‘auto’] | qlinks.backends.sparse.SparseBackend
- dtype: type[Any] | dtype[Any] | _SupportsDType[dtype[Any]] | tuple[Any, Any] | list[Any] | _DTypeDict | str | None#
- backend: Literal['scipy', 'cupy', 'auto'] | SparseBackend#
- __init__(dtype=<class 'numpy.complex128'>, on_missing='skip', drop_zero_atol=0.0, backend='scipy')#
- class qlinks.builders.SparseBuildResult(matrix, stats)[source]#
Bases:
objectSparse matrix together with build statistics.
- matrix#
Built sparse matrix.
- Type:
Any
- stats#
Counters describing the build.
- stats: SparseBuildStats#
- __init__(matrix, stats)#
- class qlinks.builders.SparseBuildStats(n_basis, n_terms, n_raw_actions, n_kept_actions, n_missing_actions, nnz)[source]#
Bases:
objectCounters collected while building a sparse matrix.
- __init__(n_basis, n_terms, n_raw_actions, n_kept_actions, n_missing_actions, nnz)#
- class qlinks.builders.SparseHamiltonianBuilder(dtype=<class 'numpy.complex128'>, on_missing='skip', combine_duplicates=True, drop_zero_atol=0.0, backend='scipy')[source]#
Bases:
objectGeneric sparse builder for configuration-space local operators.
The builder applies each operator to each basis configuration and inserts the resulting matrix element
H[row, col]. It is the most general builder and works with anyLocalOperator, at the cost of allocating full target configurations for non-diagonal actions.- dtype#
Matrix dtype.
- Type:
type[Any] | numpy.dtype[Any] | numpy._typing._dtype_like._SupportsDType[numpy.dtype[Any]] | tuple[Any, Any] | list[Any] | numpy._typing._dtype_like._DTypeDict | str | None
- on_missing#
Policy for actions outside the basis.
"skip"drops them;"raise"turns them into aKeyError.- Type:
Literal[‘skip’, ‘raise’]
- combine_duplicates#
Whether to combine multiple actions from the same column to the same target before insertion.
- Type:
- backend#
Sparse backend name or backend object.
- Type:
Literal[‘scipy’, ‘cupy’, ‘auto’] | qlinks.backends.sparse.SparseBackend
- dtype: type[Any] | dtype[Any] | _SupportsDType[dtype[Any]] | tuple[Any, Any] | list[Any] | _DTypeDict | str | None#
- backend: Literal['scipy', 'cupy', 'auto'] | SparseBackend#
- __init__(dtype=<class 'numpy.complex128'>, on_missing='skip', combine_duplicates=True, drop_zero_atol=0.0, backend='scipy')#
- qlinks.builders.build_optimized_sparse_hamiltonian(basis, operators, *, dtype=<class 'numpy.complex128'>, on_missing='skip', drop_zero_atol=0.0, backend='scipy')[source]#
Build a sparse Hamiltonian using update-style operators.
- Parameters:
basis (Basis) – Basis that fixes the matrix row/column order.
operators (Sequence[LocalUpdateOperator | DiagonalLocalOperator]) – Operators supporting
diagonal_valueorapply_update.dtype (type[Any] | dtype[Any] | _SupportsDType[dtype[Any]] | tuple[Any, Any] | list[Any] | _DTypeDict | str | None) – Matrix dtype.
on_missing (Literal['skip', 'raise']) – Policy for actions outside the basis.
drop_zero_atol (float) – Absolute threshold for dropping small coefficients.
backend (Literal['scipy', 'cupy', 'auto'] | ~qlinks.backends.sparse.SparseBackend) – Sparse backend name or backend object.
- Returns:
Sparse Hamiltonian matrix.
- Return type:
- qlinks.builders.build_sparse_hamiltonian(basis, operators, *, dtype=<class 'numpy.complex128'>, on_missing='skip', combine_duplicates=True, drop_zero_atol=0.0, backend='scipy')[source]#
Build a sparse Hamiltonian from local operators.
- Parameters:
basis (Basis) – Basis that fixes the matrix row/column order.
operators (Sequence[LocalOperator]) – Local operators to sum.
dtype (type[Any] | dtype[Any] | _SupportsDType[dtype[Any]] | tuple[Any, Any] | list[Any] | _DTypeDict | str | None) – Matrix dtype.
on_missing (Literal['skip', 'raise']) – Policy for actions outside the basis.
combine_duplicates (bool) – Whether to combine duplicate column actions before inserting them.
drop_zero_atol (float) – Absolute threshold for dropping small coefficients.
backend (Literal['scipy', 'cupy', 'auto'] | ~qlinks.backends.sparse.SparseBackend) – Sparse backend name or backend object.
- Returns:
Sparse Hamiltonian matrix.
- Return type: