33 use iso_fortran_env,
only: output_unit
40 integer,
parameter :: vecops = 10000
42 complex(WP),
dimension(:),
allocatable :: coeffs, roots
43 integer :: error, ctr, status, itr
46 real(wp) :: starttime, endtime
48 type(vector) :: rvec, rvec1
49 type(
relem) :: rd1, rd2
50 class(vecelem),
dimension(:),
allocatable :: vecarr
52 type(list) :: list1, list2
53 class(*),
allocatable :: item1
59 coeffs = [
complex(WP):: 1e-200_wp, (0,-1e200_wp), 1, 100]
63 call polyroots(coeffs, roots, error, balanceon = balanceon)
67 print *,
'Roots accuracy: ', &
68 sum(reshape([(coeffs(ctr)*(roots**(ubound(coeffs,1)-ctr)), &
69 ctr=1,ubound(coeffs,1))],[ubound(roots,1),ubound(coeffs,1)]),2)
75 print
'(1A60,3I6)',
'Vector: capacity, size, Used Buckets: ', rvec%Capacity(), rvec%Size(), rvec%NUsedBkts()
76 call rvec%Init(1, 5, rd1)
77 print
'(1A60,3I6)',
'Vector init: capacity, size, Used Buckets: ', rvec%Capacity(), rvec%Size(), rvec%NUsedBkts()
82 print
'(1A60,3I6)',
'Vector reserved 49: capacity, size, Used Buckets: ', rvec%Capacity(), rvec%Size(), rvec%NUsedBkts()
83 ctr = rvec%PushBack(rd1)
84 ctr = rvec%PushBack(rd1)
86 call rvec%ShrinkToFit()
87 print
'(1A60,3I6)',
'added 1 & shrunk: capacity, size, Used Buckets: ', rvec%Capacity(), rvec%Size(), rvec%NUsedBkts()
91 call rvec%Insert(2,[rd1],3)
93 call rvec%Insert(5,[rd1],3)
94 print
'(1A60,3I6)',
'Vector insert 6: capacity, size, Used Buckets: ', rvec%Capacity(), rvec%Size(), rvec%NUsedBkts()
96 ctr = rvec%PushBack(rd1)
98 print
'(1A60,3I6)',
'Vector push 1 & erase 2: capacity, size, Used Buckets: ', rvec%Capacity(), rvec%Size(), rvec%NUsedBkts()
101 do ctr = 1, rvec%Size()
102 rd2 = rvec%ElemAt(ctr)
103 print *,
'int(', ctr,
')=', rd2%rdata
107 call cpu_time(starttime)
109 vecarr = rvec%Slice(1,6,1)
111 call cpu_time(endtime)
114 type is (invalidvecelem)
115 print *,
'Invalid Elem'
119 print *,
'Slice time: ', (endtime-starttime)
121 call cpu_time(starttime)
124 vecarr = rvec%BktSlice(1,itr)
126 call cpu_time(endtime)
129 type is (invalidvecelem)
130 print *,
'Invalid Elem'
132 print *, vecarr(1:
size(vecarr))
134 print *,
'Bkt Slice time: ', (endtime-starttime)
137 call rvec1%Init(3, 2, rd1)
139 ctr = rvec1%PushBack(rd1)
140 print *,
'before assignment'
141 do ctr = 1, rvec1%Size()
142 rd2 = rvec1%ElemAt(ctr)
143 print *,
'int(', ctr,
')=', rd2%rdata
146 print *,
'after assignment'
147 do ctr = 1, rvec1%Size()
148 rd2 = rvec1%ElemAt(ctr)
149 print *,
'int(', ctr,
')=', rd2%rdata
154 print *,
'after clear'
155 do ctr = 1, rvec1%Size()
156 rd2 = rvec1%ElemAt(ctr)
157 print *,
'int(', ctr,
')=', rd2%rdata
163 ctr = list1%PushBack(1.8)
164 ctr = list1%PushBack(4)
165 ctr = list1%PushBack(rd1)
166 ctr = list1%PushBack(
'list item')
167 item1 = list1%PopBack()
169 type is (
character(len=*))
172 call list1%Insert(4,40)
174 call list1%ShrinktoFit()
176 do ctr = 1, list2%Size()
177 item1 = list2%Item(ctr)