# (C) Copyright IBM 2025.## This code is licensed under the Apache License, Version 2.0. You may# obtain a copy of this license in the LICENSE.txt file in the root directory# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.## Any modifications or derivative works of this code must retain this# copyright notice, and modified files need to carry a notice indicating# that they have been altered from the originals."""Convenience functions for computing the dimensions of the FCI space."""from__future__importannotationsimportmath
[docs]defdims(norb:int,nelec:tuple[int,int])->tuple[int,int]:"""Get the dimensions of the FCI space. Args: norb: The number of spatial orbitals. nelec: The number of alpha and beta electrons. Returns: A pair of integers (dim_a, dim_b) representing the dimensions of the alpha- and beta- FCI space. """n_alpha,n_beta=nelecdim_a=math.comb(norb,n_alpha)dim_b=math.comb(norb,n_beta)returndim_a,dim_b
[docs]defdim(norb:int,nelec:int|tuple[int,int])->int:"""Get the dimension of the FCI space. Args: norb: The number of spatial orbitals. nelec: Either a single integer representing the number of fermions for a spinless system, or a pair of integers storing the numbers of spin alpha and spin beta fermions. Returns: The dimension of the FCI space. """ifisinstance(nelec,int):returnmath.comb(norb,nelec)n_alpha,n_beta=nelecreturnmath.comb(norb,n_alpha)*math.comb(norb,n_beta)