Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register more Intrinsic Trig Functions #1754

Merged
merged 1 commit into from
Apr 30, 2023
Merged

Conversation

faze-geek
Copy link
Contributor

Sinh, Cosh, Tanh are intrinsic built in functions in Fortran. They can be directly added in Lfortran as well.

Example - Sinh results

import cmath
import math
def f():
    print(math.sin(1.5))
    print(cmath.sinh(complex(1,2)))
f()
(lp) C:\Users\kunni\lpython>python try.py
0.9974949866040544
(-0.4890562590412937+1.4031192506220405j)

(lp) C:\Users\kunni\lpython>src\bin\lpython try.py
9.97494986604054446e-01
(-0.489056,1.403119)

@faze-geek
Copy link
Contributor Author

@Thirumalai-Shaktivel this is just an expansion of your commit 3812ea4 . Can you have a look.

@Thirumalai-Shaktivel
Copy link
Collaborator

LGTM!

@faze-geek
Copy link
Contributor Author

faze-geek commented Apr 29, 2023

Tests from the math.py implementation are already present and work as expected. So I didn't add any separately.

def test_hyperbolic():
eps: f64 = 1e-12
assert abs(sinh(1.0) - 1.1752011936438014) < eps
assert abs(cosh(1.0) - 1.5430806348152437) < eps
assert abs(tanh(1.0) - 0.7615941559557649) < eps

@certik certik changed the title Register more Intrinsic Trigo Functions Register more Intrinsic Trig Functions Apr 30, 2023
Copy link
Contributor

@certik certik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that looks good.

@certik certik merged commit 7b7336a into lcompilers:main Apr 30, 2023
@faze-geek faze-geek deleted the trigo branch June 25, 2023 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants