Closed
Description
Below I have provided some links to get started and then explained what you both are supposed to do,
Links to get started
- https://github.com/lcompilers/lpython/blob/main/src/runtime/lpython_intrinsic_numpy.py - Contains definitions of
sin
,cos
,tan
,log
,log2
,log10
,sqrt
forf32
andf64
types. Some points to be noted - i)@vectorize
decorator automatically vectorizes the function. Now by "vectorizes the function" I mean even if the functions are defined for single number input and single number outputs, you can call them upon are array inputs as well. - https://github.com/lcompilers/lpython/blob/main/integration_tests/elemental_01.py, https://github.com/lcompilers/lpython/blob/main/integration_tests/elemental_04.py - These are the test files for NumPy functions. You can see how
sin
,cos
,log
are called with array inputs even though they were defined for single input and single output.@vectorize
does the job for you. You can also notice how the functions are tested. You can make the tests as natural/complicated as you want to. For example for testingsin
,cos
simultaneously, you can just verifysin(array)**2 + cos(array)**2 == 1
. Similarly for trigonometric function, you can take a few trigonometric identities and try verifying them in the tests (with 1d, 2d, 5d, 6d, etc arrays as inputs). In fact you can also try finding the derivative of functions using arrays. For example for a functionf
, you can do(f(array + harray) - f(array))/harray
and match with the formula you know for derivative off
you know. Bottomline is you can use your creativity to the full extent to write interesting test cases. In case you get errors don't work around the test case, instead let me know and I will fix the error for you.
Overall this task is easy-medium. Easy because extending src/runtime/lpython_intrinsic_numpy.py
is fairly easy (just follow the already existing pattern) and medium because writing test cases requires some creativity and effort.
What you have to do?
-
sinh
- Sinh & cosh numpy_intrinsic functions implemented #1002 -
cosh
- Sinh & cosh numpy_intrinsic functions implemented #1002 -
tanh
- Implement tanh and exp in Numpy_intrinsic library #1064 -
exp
- Implement tanh and exp in Numpy_intrinsic library #1064 -
arcsinh
-
arccosh
-
arctanh
-
fix
-
floor
-
ceil
-
trunc
If you complete the above tasks then please let me know. Feel free to reach out if you have any questions. :-)