Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
H
handyG
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
McMule
handyG
Commits
1be3dd9b
Commit
1be3dd9b
authored
Apr 29, 2019
by
Luca Naterop
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
function to count amount of trailing zeroes
parent
d8ec8762
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
44 deletions
+58
-44
gpl_module.f90
gpl_module.f90
+15
-12
test.f90
test.f90
+2
-4
utils.f90
utils.f90
+41
-28
No files found.
gpl_module.f90
View file @
1be3dd9b
...
...
@@ -44,12 +44,13 @@ CONTAINS
! used to compute the value of GPL when all zi are zero
integer
::
l
complex
(
kind
=
prec
)
::
y
,
GPL_zero_zi
print
*
,
'computed value using z
ero
'
print
*
,
'computed value using z
i = 0
'
GPL_zero_zi
=
1.0d0
/
factorial
(
l
)
*
log
(
y
)
**
l
END
FUNCTION
GPL_zero_zi
FUNCTION
G_with_flat_args
(
z_flat
,
y
)
result
(
res
)
! Calls G function with flat arguments, that is, zeroes not passed through the m's.
complex
(
kind
=
prec
)
::
z_flat
(:),
y
,
res
complex
(
kind
=
prec
),
allocatable
::
z
(:)
integer
::
m_prime
(
size
(
z_flat
)),
condensed_size
...
...
@@ -73,29 +74,31 @@ CONTAINS
! computes the generalized polylogarithm G_{m1,..mk} (z1,...zk; y)
! assumes zero arguments expressed through the m's
integer
::
m
(:),
k
,
i
integer
::
m
(:),
k
,
i
,
kminusj
complex
(
kind
=
prec
)
::
z
(:),
x
(
k
),
y
,
res
,
c
(
sum
(
m
)
+1
,
sum
(
m
)
+1
),
z_flat
(
sum
(
m
)),
a
(
sum
(
m
)
-1
)
! print*, 'z = ', abs(get_flattened_z(m,z))
! are all z_i = 0 ?
if
(
k
==
1
.and.
abs
(
z
(
1
))
<
zero
)
then
if
(
k
==
1
.and.
abs
(
z
(
1
))
==
0
)
then
! assumes that the zeros at the beginning are passed through m1
res
=
GPL_zero_zi
(
m
(
1
),
y
)
return
end
if
! need to remove trailing zeros?
if
(
abs
(
z
(
k
))
<
zero
)
then
print
*
,
'need to remove trailing zeros'
if
(
abs
(
z
(
k
))
==
0
)
then
print
*
,
'need to remove trailing zeros'
! which we do in flat form
! flatten z
z_flat
=
get_flattened_z
(
m
,
z
)
a
=
z_flat
(
1
:
(
size
(
z_flat
)
-1
))
c
=
shuffle_with_zero
(
a
)
res
=
G_with_flat_args
(
a
,
y
)
*
log
(
y
)
do
i
=
2
,
k
res
=
res
-
G_with_flat_args
(
c
(
i
,:),
y
)
end
do
return
res
=
G_with_flat_args
(
z_flat
,
y
)
! a = z_flat(1: (size(z_flat)-1))
! c = shuffle_with_zero(a)
! res = G_with_flat_args(a,y)*log(y)
! do i = 2,k
! res = res - G_with_flat_args(c(i,:),y)
! end do
! return
end
if
! need make convergent?
...
...
test.f90
View file @
1be3dd9b
...
...
@@ -85,11 +85,9 @@ CONTAINS
ref
=
dcmplx
(
0.0020332632172573974
)
call
test_one_GPL
((/
4
/),
cmplx
((/
0
/)),
cmplx
(
1.6
),
1
,
ref
,
'2.3'
)
!
ref = dcmplx(0.0020332632172573974)
!
call test_one_GPL((/ 1,1 /),cmplx((/ 1.7,0.0 /)),cmplx(1.1),2,ref,'2.4')
ref
=
dcmplx
(
0.0020332632172573974
)
call
test_one_GPL
((/
1
,
1
/),
cmplx
((/
1.7
,
0.0
/)),
cmplx
(
1.1
),
2
,
ref
,
'2.4'
)
! ref = dcmplx(0.0020332632172573974)
! call test_one_GPL((/ 1 /),(/(0.7,epsilon)/),(1.1,1.4),1,ref,'2.4')
end
subroutine
do_GPL_tests
END
PROGRAM
TEST
utils.f90
View file @
1be3dd9b
...
...
@@ -12,7 +12,6 @@
MODULE
utils
implicit
none
integer
,
parameter
::
prec
=
selected_real_kind
(
15
,
32
)
real
,
parameter
::
zero
=
1.0e-50
! logical :: print_enabled = .true.
! logical :: warnings_enabled = .true.
...
...
@@ -61,6 +60,19 @@ CONTAINS
end
do
END
FUNCTION
get_flattened_z
FUNCTION
find_amount_trailing_zeros
(
z
)
result
(
res
)
complex
(
kind
=
prec
)
::
z
(:)
integer
::
res
,
i
res
=
0
do
i
=
size
(
z
),
1
,
-1
if
(
z
(
i
)
==
0
)
then
res
=
res
+
1
else
exit
end
if
end
do
END
FUNCTION
find_amount_trailing_zeros
FUNCTION
find_first_zero
(
v
)
result
(
res
)
! returns index of first zero, or -1 if there is no zero
integer
::
v
(:),
i
,
res
...
...
@@ -119,33 +131,34 @@ END MODULE utils
! use utils
! implicit none
! complex(kind=prec), dimension(3) :: a = cmplx((/1,2,3/))
! complex(kind=prec) :: z_flat(2)
! complex(kind=prec), allocatable :: z(:)
! integer :: m_prime(2), condensed_size
! integer, allocatable :: m(:)
! complex(kind=prec) :: b(size(a)+1,size(a)+1)
! ! ! test shuffling
! ! b = 1
! ! b = shuffle_with_zero(a)
! ! call print_as_matrix(b)
! ! test condensing
! z_flat = cmplx((/4,0/))
! m_prime = get_condensed_m(z_flat)
! if(find_first_zero(m_prime) == -1) then
! condensed_size = size(m_prime)
! else
! condensed_size = find_first_zero(m_prime)-1
! end if
! allocate(m(condensed_size))
! allocate(z(condensed_size))
! m = m_prime(1:condensed_size)
! z = get_condensed_z(m,z_flat)
! z_flat = get_flattened_z(m,z)
! deallocate(m)
! deallocate(z)
! ! complex(kind=prec), dimension(5) :: a = cmplx((/1,2,3/))
! ! complex(kind=prec) :: z_flat(2)
! ! complex(kind=prec), allocatable :: z(:)
! ! integer :: m_prime(2), condensed_size
! ! integer, allocatable :: m(:)
! ! complex(kind=prec) :: b(size(a)+1,size(a)+1)
! ! ! ! test shuffling
! ! ! b = 1
! ! ! b = shuffle_with_zero(a)
! ! ! call print_as_matrix(b)
! ! ! test condensing
! ! z_flat = cmplx((/4,0/))
! ! m_prime = get_condensed_m(z_flat)
! ! if(find_first_zero(m_prime) == -1) then
! ! condensed_size = size(m_prime)
! ! else
! ! condensed_size = find_first_zero(m_prime)-1
! ! end if
! ! allocate(m(condensed_size))
! ! allocate(z(condensed_size))
! ! m = m_prime(1:condensed_size)
! ! z = get_condensed_z(m,z_flat)
! ! z_flat = get_flattened_z(m,z)
! ! deallocate(m)
! ! deallocate(z)
! END PROGRAM test
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment