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

meshgrid #18

Open
certik opened this issue Dec 19, 2019 · 5 comments
Open

meshgrid #18

certik opened this issue Dec 19, 2019 · 5 comments
Labels
enhancement New feature or request good first issue Good for newcomers topic: mathematics linear algebra, sparse matrices, special functions, FFT, random numbers, statistics, ...

Comments

@certik
Copy link
Member

certik commented Dec 19, 2019

Here is a 2D implementation https://github.com/certik/fortran-utils/blob/b43bd24cd421509a5bc6d3b9c3eeae8ce856ed88/src/mesh.f90#L164, but NumPy's meshgrid is much more general. Here is Matlab's meshgrid.

@jvdp1 jvdp1 added topic: algorithms searching and sorting, merging, ... topic: mathematics linear algebra, sparse matrices, special functions, FFT, random numbers, statistics, ... and removed topic: algorithms searching and sorting, merging, ... labels Jan 18, 2020
@milancurcic milancurcic added enhancement New feature or request good first issue Good for newcomers labels Mar 11, 2021
@igirault
Copy link
Contributor

Hi,
I wish to start contributing to stdlib so I am looking for a first issue to tackle. Is this issue still relevant?

If yes, should we aim for the level of genericity attained by NumPy, or is the Matlab version sufficient?

@igirault
Copy link
Contributor

If we seek to have only 2d and 3d versions, we could implement them separately under a generic interface:

interface meshgrid
  module procedure meshgrid_2d
  module procedure meshgrid_3d
end interface

where the 2d implementation for instance would be a pure subroutine with the following interface

  pure subroutine meshgrid_2d(x, y, xm, ym, indexing)
    implicit none
    real, intent(in) :: x(:)
    real, intent(in) :: y(:)
    real, intent(out) :: xm(:)
    real, intent(out) :: ym(:)
    character(len=*), intent(in), optional :: indexing
  end subroutine meshgrid_2d

The optional argument indexing would have the same influence on the result than in NumPy's meshgrid.

Of course there would also the possibility to implement meshgrid_2d / meshgrid_3d as functions rather than subroutines. In this case the output could either be encapsulated in a single array, or in a derived type.

What do you think?

@jvdp1
Copy link
Member

jvdp1 commented Jan 13, 2024

Hi @Ivanou34 , welcome and thank you for proposing to contribute to stdlib.

This issue is still relevant, and I think it is a good one to get familiar with stdlib

If yes, should we aim for the level of genericity attained by NumPy, or is the Matlab version sufficient?

Yes, it would be nice to reach the same level of genericity as NumPy. But as a first step I would suggest to first focus on 2d and 3d. See also e.g., stdlib_stats_mean.fypp, on how genericity could be achieved with the fypp preprocessor.

Your propposed API of the subroutine in your comment sounds good to me. A wrapper (e.g. function, derived type) could be added in the future, if needed.

@igirault
Copy link
Contributor

Thanks for your answer @jvdp1

Should I start working on it, or is it preferable to wait for feedback from other people?

@jvdp1
Copy link
Member

jvdp1 commented Jan 14, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers topic: mathematics linear algebra, sparse matrices, special functions, FFT, random numbers, statistics, ...
Projects
None yet
Development

No branches or pull requests

4 participants