Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/sets.f90
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,16 @@ function integers() result(res)
function basic_interval(a, b, left_open, right_open) result(res)
class(basic), intent(in) :: a, b
logical, optional :: left_open, right_open
integer(c_int) :: a_left = 1, a_right = 1
integer(c_int) :: a_left, a_right
integer(c_long) :: exception
type(basic) :: res
res = Basic()
if (present(left_open) .and. .not. left_open) then
a_left = 0
a_left = 1
a_right = 1
if (present(left_open)) then
if (.not. left_open) a_left = 0
end if
if (present(right_open) .and. .not. right_open) then
a_right = 0
if (present(right_open)) then
if (.not. right_open) a_right = 0
end if
res = Basic()
exception = c_basic_set_interval(res%ptr, a%ptr, b%ptr, a_left, a_right)
Expand Down
2 changes: 1 addition & 1 deletion src/symengine_interface.f90
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ integer(c_long) function c_basic_set_intersection(s, a, b) bind(c, name='basic_s
integer(c_long) function c_basic_set_interval(s, start, en, left_open, right_open) bind(c, name='basic_set_interval')
import :: c_long, c_int, c_ptr
type(c_ptr), value :: s, start, en
integer(c_int) :: left_open, right_open
integer(c_int), value :: left_open, right_open
end function
integer(c_long) function c_basic_set_finiteset(s, container) bind(c, name='basic_set_finiteset')
import :: c_long, c_ptr
Expand Down
6 changes: 6 additions & 0 deletions test/test_basic.f90
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,13 @@ subroutine test2()
a = SymInteger(1)
b = SymInteger(2)
c = interval(a, b)
call assert(c%str() == '(1, 2)')
c = interval(1, 2, left_open=.true., right_open=.false.)
call assert(c%str() == '(1, 2]')
c = interval(1, 2, left_open=.false.)
call assert(c%str() == '[1, 2)')
c = interval(1, 2, right_open=.true.)
call assert(c%str() == '(1, 2)')
c = interval(1, 2_int64)
c = interval(1_int64, 2)
c = interval(1_int64, 2_int64)
Expand Down
Loading