convert_index Function

public pure function convert_index(ax, ay, az)

convert from multi-index to packed tensor index

Arguments

TypeIntentOptionalAttributesName
integer, intent(in) :: ax

first () component of multi-index

integer, intent(in) :: ay

second () component of multi-index

integer, intent(in) :: az

third () component of multi-index

Return Value integer


Contents

Source Code


Source Code

integer pure function convert_index(ax, ay, az)

    !> first (\(x\)) component of multi-index
    integer, intent(in) :: ax
    !> second (\(y\)) component of multi-index
    integer, intent(in) :: ay
    !> third (\(z\)) component of multi-index
    integer, intent(in) :: az

    integer :: norm
    integer :: bx
    integer :: by
    integer :: bz

    norm = ax + ay + az

    convert_index = 1
    do bx = norm, 0, -1
        do by = norm - bx, 0, -1
            bz = norm - bx - by
            if (bx /= ax .or. by /= ay .or. bz /= az) then
                convert_index = convert_index + 1
            else
                return
            end if
        end do
    end do

end function convert_index