# create_one_spin_basis Function

## public function create_one_spin_basis(n_orbs, n_spins) result(one_spin_basis)

### Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n_orbs
integer, intent(in) :: n_spins

## Source Code

    function create_one_spin_basis(n_orbs, n_spins) result(one_spin_basis)
integer, intent(in) :: n_orbs, n_spins
integer(n_int), allocatable :: one_spin_basis(:)
#ifdef DEBUG_
character(*), parameter :: this_routine = "create_one_spin_basis"
#endif

integer :: n_max_states, i, right_zero

n_max_states = int(choose_i64(n_orbs, n_spins))

!
allocate(one_spin_basis(n_max_states))

! create the first basis state:

! implement my matlab routine to create the basis states:
! but now i have to do it for spin-orbital encoding!
! but do this afterwards so the mapping is easier for off-half-filling!
do i = 2, n_max_states

! copy last state:
one_spin_basis(i) = one_spin_basis(i - 1)

! find the right-most zero with atleast one 1 right of it
right_zero = right_most_zero(one_spin_basis(i), n_orbs)

! if the right-most zero is bigger than n_orbs already, we should
ASSERT(right_zero <= n_orbs)

! i need to count the number of 1 right of this zero
! so i want a mask where every bit right of right_zero is set
! to one

! now i want to set the right_most zero to one
one_spin_basis(i) = ibset(one_spin_basis(i), right_zero - 1)

! and everything to 0 right of it for now