← 输入框|github.com|刷新
Skip to content

Implementing hyperbolic trigonometric, exponential and rounding functions in NumPy #959

Closed

Description

@czgdp1807

Below I have provided some links to get started and then explained what you both are supposed to do,

Links to get started

  1. https://github.com/lcompilers/lpython/blob/main/src/runtime/lpython_intrinsic_numpy.py - Contains definitions of sin, cos, tan, log, log2, log10, sqrt for f32 and f64 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.
  2. 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 testing sin, cos simultaneously, you can just verify sin(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 function f, you can do (f(array + harray) - f(array))/harray and match with the formula you know for derivative of f 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?

If you complete the above tasks then please let me know. Feel free to reach out if you have any questions. :-)

Activity

  1. czgdp1807 commented on Aug 12, 2022

    @czgdp1807
    CollaboratorAuthor

    @Madhav2310 Assigning this to you (I cannot assign non-members of lcompilers Github organisation so consider this as the assignment)

  2. Madhav2310 commented on Aug 30, 2022

    @Madhav2310
  3. changed the title [-]Implementing hyperbolic trigonometric and exponential functions in NumPy[/-] [+]Implementing hyperbolic trigonometric, exponential and rounding functions in NumPy[/+] on Aug 31, 2022
  4. added
    numpy
    on Jan 24, 2023
  5. khushi-411 commented on Sep 5, 2023

    @khushi-411
    Contributor

    Hi, @czgdp1807! I'd like to work on these functions and get familiar with the codebase. The Lpython project looks interesting to me! Just wondering if I could pick the issue. Thanks :-)

  6. certik commented on Sep 5, 2023

    @certik
    Contributor

    @khushi-411 you don't need to ask, just do it.

    Many of these are already implemented, but I am sure many are still missing.

  7. khushi-411 commented on Sep 20, 2023

    @khushi-411
    Contributor

    Hi, @certik @czgdp1807!
    I think this issue could be closed as all the functions mentioned here are completed. Link
    Just wanted to share. Thanks!

  8. certik commented on Sep 20, 2023

    @certik
    Contributor

    Excellent, great job!

  9. khushi-411 commented on Sep 20, 2023

    @khushi-411
    Contributor

    Thanks for all your helpful suggestions, @certik!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    numpy

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions