sets_mod Module



Contents


Variables

Type Visibility Attributes Name Initial
integer, public :: empty_int(0) = [integer::]

Interfaces

public interface is_sorted

Check if V is sorted.

  • private pure function is_sorted_integer_int64(V, ascending) result(res)

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=int64), intent(in) :: V(:)
    logical, intent(in), optional :: ascending

    Return Value logical

  • private pure function is_sorted_integer_int32(V, ascending) result(res)

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=int32), intent(in) :: V(:)
    logical, intent(in), optional :: ascending

    Return Value logical

  • private pure function is_sorted_real_sp(V, ascending) result(res)

    Arguments

    Type IntentOptional Attributes Name
    real(kind=sp), intent(in) :: V(:)
    logical, intent(in), optional :: ascending

    Return Value logical

  • private pure function is_sorted_real_dp(V, ascending) result(res)

    Arguments

    Type IntentOptional Attributes Name
    real(kind=dp), intent(in) :: V(:)
    logical, intent(in), optional :: ascending

    Return Value logical

public interface disjoint

Check if A and B are disjoint.

  • private pure function disjoint_integer_int64(A, B) result(res)

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=int64), intent(in) :: A(:)
    integer(kind=int64), intent(in) :: B(:)

    Return Value logical

  • private pure function disjoint_integer_int32(A, B) result(res)

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=int32), intent(in) :: A(:)
    integer(kind=int32), intent(in) :: B(:)

    Return Value logical

public interface set

Create a set out of A

  • private pure function set_integer_int64(V) result(res)

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=int64), intent(in) :: V(:)

    Return Value integer(kind=int64), allocatable, (:)

  • private pure function set_integer_int32(V) result(res)

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=int32), intent(in) :: V(:)

    Return Value integer(kind=int32), allocatable, (:)

public interface is_set

Check if a given array is a set (ordered and unique elements)

  • private pure function is_set_integer_int64(V) result(res)

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=int64), intent(in) :: V(:)

    Return Value logical

  • private pure function is_set_integer_int32(V) result(res)

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=int32), intent(in) :: V(:)

    Return Value logical

public interface subset

Check if A is a subset of B.

  • private pure function subset_integer_int64(A, B) result(res)

    Check if A is a subset of B

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=int64), intent(in) :: A(:)
    integer(kind=int64), intent(in) :: B(:)

    Return Value logical

  • private pure function subset_integer_int32(A, B) result(res)

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=int32), intent(in) :: A(:)
    integer(kind=int32), intent(in) :: B(:)

    Return Value logical

public interface operator(.U.)

Calculate the union A ∪ B

  • private pure function union_integer_int64(A, B) result(D)

    Return A ∪ B Assume: 1. A and B are sorted. The result will be sorted.

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=int64), intent(in) :: A(:)
    integer(kind=int64), intent(in) :: B(:)

    Return Value integer(kind=int64), allocatable, (:)

  • private pure function union_integer_int32(A, B) result(D)

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=int32), intent(in) :: A(:)
    integer(kind=int32), intent(in) :: B(:)

    Return Value integer(kind=int32), allocatable, (:)

public interface operator(.cap.)

Calculate the intersection A ∩ B

  • private pure function intersect_integer_int64(A, B) result(D)

    Return A ∩ B Assume: 1. A and B are sorted. The result will be sorted.

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=int64), intent(in) :: A(:)
    integer(kind=int64), intent(in) :: B(:)

    Return Value integer(kind=int64), allocatable, (:)

  • private pure function intersect_integer_int32(A, B) result(D)

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=int32), intent(in) :: A(:)
    integer(kind=int32), intent(in) :: B(:)

    Return Value integer(kind=int32), allocatable, (:)

private interface operator (.complement.)

Calculate the complement A / B

  • private pure function complement_integer_int64(A, B) result(D)

    Return A / B Assume: 1. A and B are sorted. The result will be sorted.

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=int64), intent(in) :: A(:)
    integer(kind=int64), intent(in) :: B(:)

    Return Value integer(kind=int64), allocatable, (:)

  • private pure function complement_integer_int32(A, B) result(D)

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=int32), intent(in) :: A(:)
    integer(kind=int32), intent(in) :: B(:)

    Return Value integer(kind=int32), allocatable, (:)

public interface operator(.in.)

Check if element is contained in set.

  • private pure function test_in_integer_int64(element, set) result(res)

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=int64), intent(in) :: element
    integer(kind=int64), intent(in) :: set(:)

    Return Value logical

  • private pure function test_in_integer_int32(element, set) result(res)

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=int32), intent(in) :: element
    integer(kind=int32), intent(in) :: set(:)

    Return Value logical

public interface operator(.notin.)

Check if element is not contained in set.

  • private pure function test_not_in_integer_int64(element, set) result(res)

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=int64), intent(in) :: element
    integer(kind=int64), intent(in) :: set(:)

    Return Value logical

  • private pure function test_not_in_integer_int32(element, set) result(res)

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=int32), intent(in) :: element
    integer(kind=int32), intent(in) :: set(:)

    Return Value logical

public interface special_union_complement

Specialiced function with assumptions that speed up performance. Merge B into A and remove values that are in C. The result can be written with set notation as A ∪ B / C. Preconditions (not tested!): 1. C is a subset of A 2. A and B are disjoint 3. B and C are disjoint 4. A, B, and C are sorted. The result will be sorted.

  • private pure function special_union_complement_integer_int64(A, B, C) result(D)

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=int64), intent(in) :: A(:)
    integer(kind=int64), intent(in) :: B(:)
    integer(kind=int64), intent(in) :: C(:)

    Return Value integer(kind=int64), (size(A)+size(B)-size(C))

  • private pure function special_union_complement_integer_int32(A, B, C) result(D)

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=int32), intent(in) :: A(:)
    integer(kind=int32), intent(in) :: B(:)
    integer(kind=int32), intent(in) :: C(:)

    Return Value integer(kind=int32), (size(A)+size(B)-size(C))


Functions

private pure function is_sorted_integer_int64(V, ascending) result(res)

Arguments

Type IntentOptional Attributes Name
integer(kind=int64), intent(in) :: V(:)
logical, intent(in), optional :: ascending

Return Value logical

private pure function is_sorted_integer_int32(V, ascending) result(res)

Arguments

Type IntentOptional Attributes Name
integer(kind=int32), intent(in) :: V(:)
logical, intent(in), optional :: ascending

Return Value logical

private pure function is_sorted_real_sp(V, ascending) result(res)

Arguments

Type IntentOptional Attributes Name
real(kind=sp), intent(in) :: V(:)
logical, intent(in), optional :: ascending

Return Value logical

private pure function is_sorted_real_dp(V, ascending) result(res)

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(in) :: V(:)
logical, intent(in), optional :: ascending

Return Value logical

private pure function set_integer_int64(V) result(res)

Arguments

Type IntentOptional Attributes Name
integer(kind=int64), intent(in) :: V(:)

Return Value integer(kind=int64), allocatable, (:)

private pure function set_integer_int32(V) result(res)

Arguments

Type IntentOptional Attributes Name
integer(kind=int32), intent(in) :: V(:)

Return Value integer(kind=int32), allocatable, (:)

private pure function is_set_integer_int64(V) result(res)

Arguments

Type IntentOptional Attributes Name
integer(kind=int64), intent(in) :: V(:)

Return Value logical

private pure function is_set_integer_int32(V) result(res)

Arguments

Type IntentOptional Attributes Name
integer(kind=int32), intent(in) :: V(:)

Return Value logical

private pure function disjoint_integer_int64(A, B) result(res)

Arguments

Type IntentOptional Attributes Name
integer(kind=int64), intent(in) :: A(:)
integer(kind=int64), intent(in) :: B(:)

Return Value logical

private pure function disjoint_integer_int32(A, B) result(res)

Arguments

Type IntentOptional Attributes Name
integer(kind=int32), intent(in) :: A(:)
integer(kind=int32), intent(in) :: B(:)

Return Value logical

private pure function subset_integer_int64(A, B) result(res)

Check if A is a subset of B

Arguments

Type IntentOptional Attributes Name
integer(kind=int64), intent(in) :: A(:)
integer(kind=int64), intent(in) :: B(:)

Return Value logical

private pure function subset_integer_int32(A, B) result(res)

Arguments

Type IntentOptional Attributes Name
integer(kind=int32), intent(in) :: A(:)
integer(kind=int32), intent(in) :: B(:)

Return Value logical

private pure function special_union_complement_integer_int64(A, B, C) result(D)

Arguments

Type IntentOptional Attributes Name
integer(kind=int64), intent(in) :: A(:)
integer(kind=int64), intent(in) :: B(:)
integer(kind=int64), intent(in) :: C(:)

Return Value integer(kind=int64), (size(A)+size(B)-size(C))

private pure function special_union_complement_integer_int32(A, B, C) result(D)

Arguments

Type IntentOptional Attributes Name
integer(kind=int32), intent(in) :: A(:)
integer(kind=int32), intent(in) :: B(:)
integer(kind=int32), intent(in) :: C(:)

Return Value integer(kind=int32), (size(A)+size(B)-size(C))

private pure function union_integer_int64(A, B) result(D)

Return A ∪ B Assume: 1. A and B are sorted. The result will be sorted.

Arguments

Type IntentOptional Attributes Name
integer(kind=int64), intent(in) :: A(:)
integer(kind=int64), intent(in) :: B(:)

Return Value integer(kind=int64), allocatable, (:)

private pure function union_integer_int32(A, B) result(D)

Arguments

Type IntentOptional Attributes Name
integer(kind=int32), intent(in) :: A(:)
integer(kind=int32), intent(in) :: B(:)

Return Value integer(kind=int32), allocatable, (:)

private pure function intersect_integer_int64(A, B) result(D)

Return A ∩ B Assume: 1. A and B are sorted. The result will be sorted.

Arguments

Type IntentOptional Attributes Name
integer(kind=int64), intent(in) :: A(:)
integer(kind=int64), intent(in) :: B(:)

Return Value integer(kind=int64), allocatable, (:)

private pure function intersect_integer_int32(A, B) result(D)

Arguments

Type IntentOptional Attributes Name
integer(kind=int32), intent(in) :: A(:)
integer(kind=int32), intent(in) :: B(:)

Return Value integer(kind=int32), allocatable, (:)

private pure function complement_integer_int64(A, B) result(D)

Return A / B Assume: 1. A and B are sorted. The result will be sorted.

Arguments

Type IntentOptional Attributes Name
integer(kind=int64), intent(in) :: A(:)
integer(kind=int64), intent(in) :: B(:)

Return Value integer(kind=int64), allocatable, (:)

private pure function complement_integer_int32(A, B) result(D)

Arguments

Type IntentOptional Attributes Name
integer(kind=int32), intent(in) :: A(:)
integer(kind=int32), intent(in) :: B(:)

Return Value integer(kind=int32), allocatable, (:)

private pure function test_in_integer_int64(element, set) result(res)

Arguments

Type IntentOptional Attributes Name
integer(kind=int64), intent(in) :: element
integer(kind=int64), intent(in) :: set(:)

Return Value logical

private pure function test_in_integer_int32(element, set) result(res)

Arguments

Type IntentOptional Attributes Name
integer(kind=int32), intent(in) :: element
integer(kind=int32), intent(in) :: set(:)

Return Value logical

private pure function test_not_in_integer_int64(element, set) result(res)

Arguments

Type IntentOptional Attributes Name
integer(kind=int64), intent(in) :: element
integer(kind=int64), intent(in) :: set(:)

Return Value logical

private pure function test_not_in_integer_int32(element, set) result(res)

Arguments

Type IntentOptional Attributes Name
integer(kind=int32), intent(in) :: element
integer(kind=int32), intent(in) :: set(:)

Return Value logical