forked from lfortran/lfortran
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add tests for dgamma intrinsic
- Loading branch information
1 parent
60e6895
commit 77e3186
Showing
3 changed files
with
110 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
program intrinsics_293 | ||
use, intrinsic :: iso_fortran_env, only: dp => real64 | ||
real(dp) :: a | ||
integer :: i | ||
real(dp) :: dgamma_runtime_dp(3) = [0.875_dp, 3.367_dp, 2.140_dp] | ||
real(dp) :: dgamma_res_dp(3) | ||
real(dp) :: expected_dp(3) = [1.0896523574228969_dp, 2.8783551043979587_dp, 1.0675143148681314_dp] | ||
|
||
real(dp), parameter :: res(3) = dgamma([0.875_dp, 3.367_dp, 2.140_dp]) | ||
|
||
do i = 1, 3 | ||
print *, res(i) | ||
if (abs(res(i) - expected_dp(i)) > 1e-12_dp) error stop | ||
end do | ||
|
||
dgamma_res_dp = dgamma(dgamma_runtime_dp) | ||
|
||
do i = 1, 3 | ||
print *, dgamma_res_dp(i) | ||
if (abs(dgamma_res_dp(i) - expected_dp(i)) > 1e-12_dp) error stop | ||
end do | ||
|
||
a = dgamma(10.92839272_dp) | ||
|
||
print *, a | ||
if (a - 3067135.1568285478_dp > 1e-12_dp) error stop | ||
|
||
print *,dgamma(10.92839272_dp) | ||
if (dgamma(10.92839272_dp) - 3067135.1568285478_dp > 1e-12_dp) error stop | ||
|
||
a = dgamma(83.728927_dp) | ||
|
||
print *, a | ||
! if (abs(a - 1.1895370148607565E+124_dp) > 1e-12_dp) error stop | ||
|
||
print *,dgamma(83.728927_dp) | ||
! if (abs(dgamma(83.728927_dp) - 1.1895370148607565E+124_dp) > 1e-12_dp) error stop | ||
|
||
end program |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
program intrinsics_294 | ||
use, intrinsic :: iso_fortran_env, only: dp => real64, sp => real32 | ||
real(dp) :: a | ||
real(sp) :: d | ||
integer :: i | ||
real(dp) :: log_gamma_runtime_dp(3) = [0.875_dp, 3.367_dp, 2.140_dp] | ||
real(sp) :: log_gamma_runtime_sp(3) = [0.875, 3.367, 2.140] | ||
real(dp) :: log_gamma_res_dp(3) | ||
real(sp) :: log_gamma_res_sp(3) | ||
real(dp) :: expected_dp(3) = [8.5858707225334327E-002_dp, 1.0572189866765507_dp, 6.5332875743268432E-002_dp] | ||
real(sp) :: expected_sp(3) = [8.58587101E-02_sp, 1.05721915_sp, 6.53329268E-02] | ||
|
||
real(dp), parameter :: res(3) = log_gamma([0.875_dp, 3.367_dp, 2.140_dp]) | ||
real(sp), parameter :: res_sp(3) = log_gamma([0.875, 3.367, 2.140]) | ||
|
||
do i = 1, 3 | ||
print *, res(i) | ||
if (abs(res(i) - expected_dp(i)) > 1e-12_dp) error stop | ||
end do | ||
|
||
do i = 1, 3 | ||
print *, res_sp(i) | ||
if (abs(res_sp(i) - expected_sp(i)) > 1e-5) error stop | ||
end do | ||
|
||
log_gamma_res_dp = log_gamma(log_gamma_runtime_dp) | ||
log_gamma_res_sp = log_gamma(log_gamma_runtime_sp) | ||
|
||
do i = 1, 3 | ||
print *, log_gamma_res_dp(i) | ||
if (abs(log_gamma_res_dp(i) - expected_dp(i)) > 1e-12_dp) error stop | ||
end do | ||
|
||
do i = 1, 3 | ||
print *, log_gamma_res_sp(i) | ||
if (abs(log_gamma_res_sp(i) - expected_sp(i)) > 1e-5) error stop | ||
end do | ||
|
||
a = log_gamma(10.92839272_dp) | ||
d = log_gamma(10.92839272) | ||
|
||
print *, a | ||
if (a - 14.936254510214283_dp > 1e-12_dp) error stop | ||
|
||
print *,log_gamma(10.92839272_dp) | ||
if (log_gamma(10.92839272_dp) - 14.936254510214283_dp > 1e-12_dp) error stop | ||
|
||
print *, d | ||
if (d - 14.9362535_sp > 1e-5) error stop | ||
|
||
print *, log_gamma(10.92839272) | ||
if (log_gamma(10.92839272) - 14.9362535_sp > 1e-5) error stop | ||
|
||
a = log_gamma(83.728927_dp) | ||
d = log_gamma(31.738222) | ||
|
||
print *, a | ||
if (a - 285.69411569953820_dp > 1e-12_dp) error stop | ||
|
||
print *,log_gamma(83.728927_dp) | ||
if (log_gamma(83.728927_dp) - 285.69411569953820_dp > 1e-12_dp) error stop | ||
|
||
print *, d | ||
if (d - 77.1901703_sp > 1e-5) error stop | ||
|
||
print *, log_gamma(31.738222) | ||
if (log_gamma(31.738222) - 77.1901703_sp > 1e-5) error stop | ||
|
||
end program |