From de2dbbbc577c2115e746b2f5564671ff40988fc3 Mon Sep 17 00:00:00 2001 From: Jeremie Vandenplas Date: Sat, 8 Jul 2023 21:28:33 +0200 Subject: [PATCH 1/7] add explicity in test_stdlib_bitset_large --- test/bitsets/test_stdlib_bitset_large.f90 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/bitsets/test_stdlib_bitset_large.f90 b/test/bitsets/test_stdlib_bitset_large.f90 index 7d268b86f..ec9ede8ab 100644 --- a/test/bitsets/test_stdlib_bitset_large.f90 +++ b/test/bitsets/test_stdlib_bitset_large.f90 @@ -1,7 +1,15 @@ module test_stdlib_bitset_large use testdrive, only : new_unittest, unittest_type, error_type, check use :: stdlib_kinds, only : int8, int16, int32, int64 - use stdlib_bitsets + use stdlib_bitsets, only: bitset_large, bits_kind& + , bits & + , success & + , and, and_not, or, xor& + , extract& + , assignment(=)& + , operator(<), operator(<=)& + , operator(>), operator(>=)& + , operator(/=), operator(==) implicit none character(*), parameter :: & bitstring_0 = '000000000000000000000000000000000', & From 96763e1ea661790698bc04350926079987c95a67 Mon Sep 17 00:00:00 2001 From: Jeremie Vandenplas Date: Sat, 8 Jul 2023 21:50:02 +0200 Subject: [PATCH 2/7] add test following issue #726 --- test/bitsets/test_stdlib_bitset_large.f90 | 31 +++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/test/bitsets/test_stdlib_bitset_large.f90 b/test/bitsets/test_stdlib_bitset_large.f90 index ec9ede8ab..cd3204697 100644 --- a/test/bitsets/test_stdlib_bitset_large.f90 +++ b/test/bitsets/test_stdlib_bitset_large.f90 @@ -28,6 +28,7 @@ subroutine collect_stdlib_bitset_large(testsuite) new_unittest("string-operations", test_string_operations), & new_unittest("io", test_io), & new_unittest("initialization", test_initialization), & + new_unittest("bitset-assignment-array", test_assignment_array), & new_unittest("bitset-inquiry", test_bitset_inquiry), & new_unittest("bit-operations", test_bit_operations), & new_unittest("bitset-comparisons", test_bitset_comparisons), & @@ -558,6 +559,36 @@ subroutine test_initialization(error) end subroutine test_initialization + subroutine test_assignment_array(error) + !> Error handling + type(error_type), allocatable, intent(out) :: error + + logical(int8) :: log1(64) = .true. + + integer :: i + type(bitset_large) :: set1(0:4) + + do i = 0, size(set1) - 1 + set1(i) = log1 + enddo + + do i = 0, size(set1) - 1 + call check(error, set1(i) % bits(), 64, & + ' initialization with logical(int8) failed to set' // & + ' the right size in a bitset array.') + if (allocated(error)) return + enddo + + !Test added following issue https://github.com/fortran-lang/stdlib/issues/726 + set1(0) = set1(0) + + call check(error, set1(0) % bits(), 64, & + ' initialization from bitset_large failed to set' // & + ' the right size in a bitset array.') + if (allocated(error)) return + + end subroutine test_assignment_array + subroutine test_bitset_inquiry(error) !> Error handling type(error_type), allocatable, intent(out) :: error From 782bb12b9979747ac82c3895d45270acf28fe73e Mon Sep 17 00:00:00 2001 From: Jeremie Vandenplas Date: Sat, 22 Jul 2023 19:18:59 +0200 Subject: [PATCH 3/7] remove assign bitset_large --- src/stdlib_bitsets.fypp | 14 +++++++------- src/stdlib_bitsets_large.fypp | 20 ++++++++++---------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/stdlib_bitsets.fypp b/src/stdlib_bitsets.fypp index 0605f2792..453efd2f8 100644 --- a/src/stdlib_bitsets.fypp +++ b/src/stdlib_bitsets.fypp @@ -1166,13 +1166,13 @@ module stdlib_bitsets !! end program example_assignment !!``` - pure module subroutine assign_large( set1, set2 ) -!! Version: experimental -!! -!! Used to define assignment for `bitset_large`. - type(bitset_large), intent(out) :: set1 - type(bitset_large), intent(in) :: set2 - end subroutine assign_large +! pure module subroutine assign_large( set1, set2 ) +!!! Version: experimental +!!! +!!! Used to define assignment for `bitset_large`. +! type(bitset_large), intent(out) :: set1 +! type(bitset_large), intent(in) :: set2 +! end subroutine assign_large #:for k1 in INT_KINDS pure module subroutine assign_log${k1}$_large( self, logical_vector ) diff --git a/src/stdlib_bitsets_large.fypp b/src/stdlib_bitsets_large.fypp index 324f19741..e8cc8775c 100644 --- a/src/stdlib_bitsets_large.fypp +++ b/src/stdlib_bitsets_large.fypp @@ -89,16 +89,16 @@ contains end function any_large - pure module subroutine assign_large( set1, set2 ) -! Used to define assignment for bitset_large - type(bitset_large), intent(out) :: set1 - type(bitset_large), intent(in) :: set2 - - set1 % num_bits = set2 % num_bits - allocate( set1 % blocks( size( set2 % blocks, kind=bits_kind ) ) ) - set1 % blocks(:) = set2 % blocks(:) - - end subroutine assign_large +! pure module subroutine assign_large( set1, set2 ) +!! Used to define assignment for bitset_large +! type(bitset_large), intent(out) :: set1 +! type(bitset_large), intent(in) :: set2 +! +! set1 % num_bits = set2 % num_bits +! allocate( set1 % blocks( size( set2 % blocks, kind=bits_kind ) ) ) +! set1 % blocks(:) = set2 % blocks(:) +! +! end subroutine assign_large #:for k1 in INT_KINDS pure module subroutine assign_log${k1}$_large( self, logical_vector ) From a4ac099c7835be3179e5f07f9f06b0b40404e890 Mon Sep 17 00:00:00 2001 From: Jeremie Vandenplas Date: Sat, 22 Jul 2023 13:22:25 -0400 Subject: [PATCH 4/7] Update src/stdlib_bitsets_large.fypp --- src/stdlib_bitsets_large.fypp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/stdlib_bitsets_large.fypp b/src/stdlib_bitsets_large.fypp index e8cc8775c..fef726525 100644 --- a/src/stdlib_bitsets_large.fypp +++ b/src/stdlib_bitsets_large.fypp @@ -89,16 +89,6 @@ contains end function any_large -! pure module subroutine assign_large( set1, set2 ) -!! Used to define assignment for bitset_large -! type(bitset_large), intent(out) :: set1 -! type(bitset_large), intent(in) :: set2 -! -! set1 % num_bits = set2 % num_bits -! allocate( set1 % blocks( size( set2 % blocks, kind=bits_kind ) ) ) -! set1 % blocks(:) = set2 % blocks(:) -! -! end subroutine assign_large #:for k1 in INT_KINDS pure module subroutine assign_log${k1}$_large( self, logical_vector ) From 94f0f99cf100d936c944f0133029ea2a8f6e5f67 Mon Sep 17 00:00:00 2001 From: Jeremie Vandenplas Date: Sat, 22 Jul 2023 13:22:30 -0400 Subject: [PATCH 5/7] Update src/stdlib_bitsets.fypp --- src/stdlib_bitsets.fypp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/stdlib_bitsets.fypp b/src/stdlib_bitsets.fypp index 453efd2f8..42b5baea4 100644 --- a/src/stdlib_bitsets.fypp +++ b/src/stdlib_bitsets.fypp @@ -1166,13 +1166,6 @@ module stdlib_bitsets !! end program example_assignment !!``` -! pure module subroutine assign_large( set1, set2 ) -!!! Version: experimental -!!! -!!! Used to define assignment for `bitset_large`. -! type(bitset_large), intent(out) :: set1 -! type(bitset_large), intent(in) :: set2 -! end subroutine assign_large #:for k1 in INT_KINDS pure module subroutine assign_log${k1}$_large( self, logical_vector ) From e648ed84f4984ae64c3e3361a72adb33577ce488 Mon Sep 17 00:00:00 2001 From: Jeremie Vandenplas Date: Sat, 22 Jul 2023 19:33:55 +0200 Subject: [PATCH 6/7] remove assign bitset_64 --- src/stdlib_bitsets.fypp | 7 ------- src/stdlib_bitsets_64.fypp | 9 --------- 2 files changed, 16 deletions(-) diff --git a/src/stdlib_bitsets.fypp b/src/stdlib_bitsets.fypp index 453efd2f8..c5b6e7a8d 100644 --- a/src/stdlib_bitsets.fypp +++ b/src/stdlib_bitsets.fypp @@ -1510,13 +1510,6 @@ module stdlib_bitsets interface assignment(=) - pure module subroutine assign_64( set1, set2 ) -!! Version: experimental -!! -!! Used to define assignment for `bitset_64`. - type(bitset_64), intent(out) :: set1 - type(bitset_64), intent(in) :: set2 - end subroutine assign_64 #:for k1 in INT_KINDS module subroutine assign_log${k1}$_64( self, logical_vector ) diff --git a/src/stdlib_bitsets_64.fypp b/src/stdlib_bitsets_64.fypp index 82ad1397c..f4b25c9b9 100644 --- a/src/stdlib_bitsets_64.fypp +++ b/src/stdlib_bitsets_64.fypp @@ -72,15 +72,6 @@ contains end function any_64 - pure module subroutine assign_64( set1, set2 ) -! Used to define assignment for bitset_64 - type(bitset_64), intent(out) :: set1 - type(bitset_64), intent(in) :: set2 - - set1 % num_bits = set2 % num_bits - set1 % block = set2 % block - - end subroutine assign_64 #:for k1 in INT_KINDS From b9b4b9f1efc3c9b30fb5378d8e630b1a4fcf598a Mon Sep 17 00:00:00 2001 From: Jeremie Vandenplas Date: Sat, 22 Jul 2023 19:38:25 +0200 Subject: [PATCH 7/7] update specs --- doc/specs/stdlib_bitsets.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/specs/stdlib_bitsets.md b/doc/specs/stdlib_bitsets.md index 77da22b9b..7cbca1175 100644 --- a/doc/specs/stdlib_bitsets.md +++ b/doc/specs/stdlib_bitsets.md @@ -194,8 +194,8 @@ undefined. These procedures are summarized in the following table: ### Assignments -The module defines an assignment operation, `=`, that creates a -duplicate of an original bitset. It also defines assignments to and +The module uses the intrinsic assignment operation, `=`, to create a +duplicate of an original bitset. It additionally defines assignments to and from rank one arrays of logical type of kinds `int8`, `int16`, `int32`, and `int64`. In the assignment to and from logical arrays array index, `i`, is mapped to bit position, `pos=i-1`, and `.true.`