Skip to content

Commit

Permalink
Implemented numpy.arctan, numpy.degrees and numpy.radians
Browse files Browse the repository at this point in the history
Co-authored-by: Zhou <redbopo.lan@gmail.com>
  • Loading branch information
czgdp1807 and redbopo committed Sep 2, 2022
1 parent 37cd05a commit b91a48e
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/runtime/lpython_intrinsic_numpy.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from ltypes import f64, f32, ccall, vectorize, overload

pi_64: f64 = 3.141592653589793238462643383279502884197
pi_32: f32 = 3.141592653589793238462643383279502884197

########## sin ##########

@ccall
Expand Down Expand Up @@ -248,3 +251,46 @@ def _lfortran_sexp(x: f32) -> f32:
def exp(x: f32) -> f32:
return _lfortran_sexp(x)

########## arctan ##########

@ccall
def _lfortran_datan(x: f64) -> f64:
pass

@overload
@vectorize
def arctan(x: f64) -> f64:
return _lfortran_datan(x)

@ccall
def _lfortran_satan(x: f32) -> f32:
pass

@overload
@vectorize
def arctan(x: f32) -> f32:
return _lfortran_satan(x)

########## degrees ##########

@overload
@vectorize
def degrees(x: f64) -> f64:
return x*180/pi_64

@overload
@vectorize
def degrees(x: f32) -> f32:
return x*180/pi_32

########## radians ##########

@overload
@vectorize
def radians(x: f64) -> f64:
return x*pi_64/180

@overload
@vectorize
def radians(x: f32) -> f32:
return x*pi_32/180

0 comments on commit b91a48e

Please sign in to comment.