Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
cd7e19d
Added core files for stdlib_bitsets
wclodius2 Sep 29, 2020
e35ebc7
Prepared for testing of stdlib_bitsets
wclodius2 Sep 29, 2020
e2f3d66
Eliminated unused variablese
wclodius2 Sep 30, 2020
7d778cd
Added documentation for stdlib_bitsets
wclodius2 Sep 30, 2020
acfa3ac
Update doc/specs/stdlib_bitsets.md
jvdp1 Oct 4, 2020
7c5361c
Update doc/specs/stdlib_bitsets.md
jvdp1 Oct 4, 2020
eb2e5c1
formatting
jvdp1 Oct 4, 2020
e70c909
Update src/tests/Makefile.manual
jvdp1 Oct 4, 2020
8e25812
Update doc/specs/stdlib_bitsets.md
jvdp1 Oct 4, 2020
c9e851b
Changed makefiles to accept stdlib_bitset*.fypp instead of stdlib_bit…
wclodius2 Oct 8, 2020
d80e5d9
Renamed files stdlib_bitset*.f90 to stdlib_bitset*.fypp
wclodius2 Oct 8, 2020
f2d67fc
Changed preprocessor files to generate logical assignments.
wclodius2 Oct 8, 2020
2833ffa
Removed files now generated by the preprocessor
wclodius2 Oct 8, 2020
3844561
Modified code to use error_handler.
wclodius2 Oct 9, 2020
9e9c252
Better documented status results
wclodius2 Oct 9, 2020
421c4d2
Removed trailing blanks
wclodius2 Oct 9, 2020
d2be3dc
Added missing return
wclodius2 Oct 9, 2020
b0c0f63
Changed WRiTE to WRITE
wclodius2 Oct 9, 2020
b12e398
Changed the kind of bit
wclodius2 Oct 9, 2020
983a083
Changed subtraction of bit from outside an int converson to inside
wclodius2 Oct 9, 2020
38095c0
Deleted redundant returns.
wclodius2 Oct 10, 2020
cc477b9
Deleted redundant return
wclodius2 Oct 10, 2020
beca325
Regularized code fences
wclodius2 Oct 10, 2020
d391970
Some typs and obvious changes
jvdp1 Oct 14, 2020
84d7d33
Apply suggestions from code review
jvdp1 Oct 14, 2020
d6dc6b1
Corrected stdlib_bitsets.md
wclodius2 Oct 15, 2020
daa83d2
Update doc/specs/stdlib_bitsets.md
jvdp1 Oct 15, 2020
30c2116
Apply suggestions from code review
jvdp1 Oct 15, 2020
0e3b788
Merge branch 'bitsets3' of https://github.com/wclodius2/stdlib into b…
wclodius2 Oct 15, 2020
adab166
Changed file names
wclodius2 Oct 15, 2020
d7cf384
Updated makefiles to deal with new names
wclodius2 Oct 15, 2020
aeae7dd
Changed discussion of bitset_type
wclodius2 Oct 15, 2020
8330945
Changed varibles to entities.
wclodius2 Oct 15, 2020
24881a5
Fixed typo in Makefile.manual
wclodius2 Oct 15, 2020
0554f5d
typos
jvdp1 Oct 15, 2020
ecd6c82
Typos and bits_kind fixes
wclodius2 Oct 16, 2020
47c7d6e
Fixed digit_count
wclodius2 Oct 16, 2020
80af2c5
Added dependence on stdlib_kinds.f90
wclodius2 Oct 16, 2020
0deab15
Fixed bits_kind breakage
wclodius2 Oct 16, 2020
9f0e4a9
Fixed up constants
wclodius2 Oct 16, 2020
9f690fd
some typos
jvdp1 Oct 16, 2020
f705346
Added discussion of undefined behavior
wclodius2 Oct 19, 2020
242950b
Fixed typo
wclodius2 Oct 19, 2020
032c440
Added reference to the bitsets module
wclodius2 Oct 19, 2020
e957342
Made it easier to change bits_kind
wclodius2 Oct 20, 2020
9161fc7
Replaced go to 100 with exit
wclodius2 Oct 20, 2020
3235ab4
Changed used modues
wclodius2 Oct 20, 2020
523dbc6
Changed handling of potential integer overflows on reads
wclodius2 Oct 21, 2020
20a15e5
Numerous changes suggested by Jeremie
wclodius2 Oct 21, 2020
57faccd
Replaced go tos
wclodius2 Oct 21, 2020
9c03d16
Replaced go tos
wclodius2 Oct 21, 2020
5c2779d
Documented the "named" form for the comparison operations
wclodius2 Oct 26, 2020
99fa382
typography fixes
milancurcic Nov 13, 2020
acb7cdb
add example to the first paragraph
milancurcic Nov 13, 2020
1be7ca3
Merge https://github.com/fortran-lang/stdlib into bitsets3
wclodius2 Nov 14, 2020
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Renamed files stdlib_bitset*.f90 to stdlib_bitset*.fypp
Renamed files stdlib_bitset*.f90 to fypp preprocessor stdlib_bitset*.fypp files [ticket: X]
  • Loading branch information
wclodius2 committed Oct 8, 2020
commit d80e5d9e374491168077aa7bf0d84ffc4ed3d943
122 changes: 58 additions & 64 deletions src/stdlib_bitset_64.f90
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pure module subroutine assign_64( set1, set2 )
end subroutine assign_64


module subroutine assign_log8_64( self, logical_vector )
module subroutine assign_logint8_64( self, logical_vector )
! Used to define assignment from an array of type logical for bitset_64
type(bitset_64), intent(out) :: self
logical(int8), intent(in) :: logical_vector(:)
Expand All @@ -104,38 +104,30 @@ module subroutine assign_log8_64( self, logical_vector )
end if
end do

end subroutine assign_log8_64
end subroutine assign_logint8_64


module subroutine assign_log16_64( self, logical_vector )
! Used to define assignment from an array of type logical for bitset_64
type(bitset_64), intent(out) :: self
logical(int16), intent(in) :: logical_vector(:)
pure module subroutine logint8_assign_64( logical_vector, set )
! Used to define assignment to an array of type logical for bitset_64
logical(int8), intent(out), allocatable :: logical_vector(:)
type(bitset_64), intent(in) :: set

integer(bits_kind) :: log_size
integer(bits_kind) :: index

log_size = size( logical_vector, kind=bits_kind )
if ( log_size > 64 ) then
error stop module_name // ' % ' // 'ASSIGNMENT' // " has " // &
"SIZE(LOGICAL_VECTOR) > 64 with assignment to a BITSET_64."
end if
self % num_bits = log_size
self % block = 0

do index=0, log_size-1
if ( logical_vector(index+1) ) then
self % block = ibset( self % block, index )
allocate( logical_vector( set % num_bits ) )
do index=0, set % num_bits-1
if ( set % value( index ) == 1 ) then
logical_vector(index+1) = .true.
else
logical_vector(index+1) = .false.
end if
end do

end subroutine assign_log16_64


module subroutine assign_log32_64( self, logical_vector )
end subroutine logint8_assign_64
module subroutine assign_logint16_64( self, logical_vector )
! Used to define assignment from an array of type logical for bitset_64
type(bitset_64), intent(out) :: self
logical(int32), intent(in) :: logical_vector(:)
logical(int16), intent(in) :: logical_vector(:)

integer(bits_kind) :: log_size
integer(bits_kind) :: index
Expand All @@ -154,13 +146,30 @@ module subroutine assign_log32_64( self, logical_vector )
end if
end do

end subroutine assign_log32_64
end subroutine assign_logint16_64


pure module subroutine logint16_assign_64( logical_vector, set )
! Used to define assignment to an array of type logical for bitset_64
logical(int16), intent(out), allocatable :: logical_vector(:)
type(bitset_64), intent(in) :: set

integer(bits_kind) :: index

allocate( logical_vector( set % num_bits ) )
do index=0, set % num_bits-1
if ( set % value( index ) == 1 ) then
logical_vector(index+1) = .true.
else
logical_vector(index+1) = .false.
end if
end do

module subroutine assign_log64_64( self, logical_vector )
end subroutine logint16_assign_64
module subroutine assign_logint32_64( self, logical_vector )
! Used to define assignment from an array of type logical for bitset_64
type(bitset_64), intent(out) :: self
logical(int64), intent(in) :: logical_vector(:)
logical(int32), intent(in) :: logical_vector(:)

integer(bits_kind) :: log_size
integer(bits_kind) :: index
Expand All @@ -179,12 +188,12 @@ module subroutine assign_log64_64( self, logical_vector )
end if
end do

end subroutine assign_log64_64
end subroutine assign_logint32_64


pure module subroutine log8_assign_64( logical_vector, set )
pure module subroutine logint32_assign_64( logical_vector, set )
! Used to define assignment to an array of type logical for bitset_64
logical(int8), intent(out), allocatable :: logical_vector(:)
logical(int32), intent(out), allocatable :: logical_vector(:)
type(bitset_64), intent(in) :: set

integer(bits_kind) :: index
Expand All @@ -198,51 +207,36 @@ pure module subroutine log8_assign_64( logical_vector, set )
end if
end do

end subroutine log8_assign_64


pure module subroutine log16_assign_64( logical_vector, set )
! Used to define assignment to an array of type logical for bitset_64
logical(int16), intent(out), allocatable :: logical_vector(:)
type(bitset_64), intent(in) :: set
end subroutine logint32_assign_64
module subroutine assign_logint64_64( self, logical_vector )
! Used to define assignment from an array of type logical for bitset_64
type(bitset_64), intent(out) :: self
logical(int64), intent(in) :: logical_vector(:)

integer(bits_kind) :: log_size
integer(bits_kind) :: index

allocate( logical_vector( set % num_bits ) )
do index=0, set % num_bits-1
if ( set % value( index ) == 1 ) then
logical_vector(index+1) = .true.
else
logical_vector(index+1) = .false.
end if
end do

end subroutine log16_assign_64


pure module subroutine log32_assign_64( logical_vector, set )
! Used to define assignment to an array of type logical for bitset_64
logical(int32), intent(out), allocatable :: logical_vector(:)
type(bitset_64), intent(in) :: set

integer(bits_kind) :: index
log_size = size( logical_vector, kind=bits_kind )
if ( log_size > 64 ) then
error stop module_name // ' % ' // 'ASSIGNMENT' // " has " // &
"SIZE(LOGICAL_VECTOR) > 64 with assignment to a BITSET_64."
end if
self % num_bits = log_size
self % block = 0

allocate( logical_vector( set % num_bits ) )
do index=0, set % num_bits-1
if ( set % value( index ) == 1 ) then
logical_vector(index+1) = .true.
else
logical_vector(index+1) = .false.
do index=0, log_size-1
if ( logical_vector(index+1) ) then
self % block = ibset( self % block, index )
end if
end do

end subroutine log32_assign_64
end subroutine assign_logint64_64


pure module subroutine log64_assign_64( logical_vector, set )
pure module subroutine logint64_assign_64( logical_vector, set )
! Used to define assignment to an array of type logical for bitset_64
logical(int64), intent(out), allocatable :: logical_vector(:)
type(bitset_64), intent(in) :: set
type(bitset_64), intent(in) :: set

integer(bits_kind) :: index

Expand All @@ -255,7 +249,7 @@ pure module subroutine log64_assign_64( logical_vector, set )
end if
end do

end subroutine log64_assign_64
end subroutine logint64_assign_64


elemental module function bit_count_64(self) result(bit_count)
Expand Down
129 changes: 61 additions & 68 deletions src/stdlib_bitset_large.f90
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ pure module subroutine assign_large( set1, set2 )

end subroutine assign_large


pure module subroutine assign_log8_large( self, logical_vector )
pure module subroutine assign_logint8_large( self, logical_vector )
! Used to define assignment from an array of type logical for bitset_large
type(bitset_large), intent(out) :: self
logical(int8), intent(in) :: logical_vector(:)
Expand All @@ -125,41 +124,30 @@ pure module subroutine assign_log8_large( self, logical_vector )
end if
end do

end subroutine assign_log8_large
end subroutine assign_logint8_large


pure module subroutine assign_log16_large( self, logical_vector )
! Used to define assignment from an array of type logical for bitset_large
type(bitset_large), intent(out) :: self
logical(int16), intent(in) :: logical_vector(:)
pure module subroutine logint8_assign_large( logical_vector, set )
! Used to define assignment to an array of type logical for bitset_large
logical(int8), intent(out), allocatable :: logical_vector(:)
type(bitset_large), intent(in) :: set

integer(bits_kind) :: blocks
integer(bits_kind) :: log_size
integer(bits_kind) :: index

log_size = size( logical_vector, kind=bits_kind )
self % num_bits = log_size
if ( log_size == 0 ) then
blocks = 0
else
blocks = (log_size-1)/block_size + 1
end if
allocate( self % blocks( blocks ) )
self % blocks(:) = 0

do index=0, log_size-1
if ( logical_vector(index+1) ) then
call self % set( index )
allocate( logical_vector( set % num_bits ) )
do index=0, set % num_bits-1
if ( set % value( index ) == 1 ) then
logical_vector(index+1) = .true.
else
logical_vector(index+1) = .false.
end if
end do

end subroutine assign_log16_large


pure module subroutine assign_log32_large( self, logical_vector )
end subroutine logint8_assign_large
pure module subroutine assign_logint16_large( self, logical_vector )
! Used to define assignment from an array of type logical for bitset_large
type(bitset_large), intent(out) :: self
logical(int32), intent(in) :: logical_vector(:)
logical(int16), intent(in) :: logical_vector(:)

integer(bits_kind) :: blocks
integer(bits_kind) :: log_size
Expand All @@ -181,13 +169,30 @@ pure module subroutine assign_log32_large( self, logical_vector )
end if
end do

end subroutine assign_log32_large
end subroutine assign_logint16_large


pure module subroutine logint16_assign_large( logical_vector, set )
! Used to define assignment to an array of type logical for bitset_large
logical(int16), intent(out), allocatable :: logical_vector(:)
type(bitset_large), intent(in) :: set

integer(bits_kind) :: index

allocate( logical_vector( set % num_bits ) )
do index=0, set % num_bits-1
if ( set % value( index ) == 1 ) then
logical_vector(index+1) = .true.
else
logical_vector(index+1) = .false.
end if
end do

pure module subroutine assign_log64_large( self, logical_vector )
end subroutine logint16_assign_large
pure module subroutine assign_logint32_large( self, logical_vector )
! Used to define assignment from an array of type logical for bitset_large
type(bitset_large), intent(out) :: self
logical(int64), intent(in) :: logical_vector(:)
logical(int32), intent(in) :: logical_vector(:)

integer(bits_kind) :: blocks
integer(bits_kind) :: log_size
Expand All @@ -209,12 +214,12 @@ pure module subroutine assign_log64_large( self, logical_vector )
end if
end do

end subroutine assign_log64_large
end subroutine assign_logint32_large


pure module subroutine log8_assign_large( logical_vector, set )
pure module subroutine logint32_assign_large( logical_vector, set )
! Used to define assignment to an array of type logical for bitset_large
logical(int8), intent(out), allocatable :: logical_vector(:)
logical(int32), intent(out), allocatable :: logical_vector(:)
type(bitset_large), intent(in) :: set

integer(bits_kind) :: index
Expand All @@ -228,51 +233,39 @@ pure module subroutine log8_assign_large( logical_vector, set )
end if
end do

end subroutine log8_assign_large


pure module subroutine log16_assign_large( logical_vector, set )
! Used to define assignment to an array of type logical for bitset_large
logical(int16), intent(out), allocatable :: logical_vector(:)
type(bitset_large), intent(in) :: set
end subroutine logint32_assign_large
pure module subroutine assign_logint64_large( self, logical_vector )
! Used to define assignment from an array of type logical for bitset_large
type(bitset_large), intent(out) :: self
logical(int64), intent(in) :: logical_vector(:)

integer(bits_kind) :: blocks
integer(bits_kind) :: log_size
integer(bits_kind) :: index

allocate( logical_vector( set % num_bits ) )
do index=0, set % num_bits-1
if ( set % value( index ) == 1 ) then
logical_vector(index+1) = .true.
else
logical_vector(index+1) = .false.
end if
end do

end subroutine log16_assign_large


pure module subroutine log32_assign_large( logical_vector, set )
! Used to define assignment to an array of type logical for bitset_large
logical(int32), intent(out), allocatable :: logical_vector(:)
type(bitset_large), intent(in) :: set

integer(bits_kind) :: index
log_size = size( logical_vector, kind=bits_kind )
self % num_bits = log_size
if ( log_size == 0 ) then
blocks = 0
else
blocks = (log_size-1)/block_size + 1
end if
allocate( self % blocks( blocks ) )
self % blocks(:) = 0

allocate( logical_vector( set % num_bits ) )
do index=0, set % num_bits-1
if ( set % value( index ) == 1 ) then
logical_vector(index+1) = .true.
else
logical_vector(index+1) = .false.
do index=0, log_size-1
if ( logical_vector(index+1) ) then
call self % set( index )
end if
end do

end subroutine log32_assign_large
end subroutine assign_logint64_large


pure module subroutine log64_assign_large( logical_vector, set )
pure module subroutine logint64_assign_large( logical_vector, set )
! Used to define assignment to an array of type logical for bitset_large
logical(int64), intent(out), allocatable :: logical_vector(:)
type(bitset_large), intent(in) :: set
type(bitset_large), intent(in) :: set

integer(bits_kind) :: index

Expand All @@ -285,7 +278,7 @@ pure module subroutine log64_assign_large( logical_vector, set )
end if
end do

end subroutine log64_assign_large
end subroutine logint64_assign_large


elemental module function bit_count_large(self) result(bit_count)
Expand Down
Loading