-
Notifications
You must be signed in to change notification settings - Fork 178
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
linspace and logspace #17
Comments
A minor downside of mirroring the numpy API, is that since the |
Have you ever used the |
Along the lines of "Let's use pure Fortran whenever we can" from #20, I suggest we aim for If we have an |
I have used the step argument before. A simple use case is setting up a simple finite difference method: x = linspace(0.0_dp,1.0_dp,101,step=dx)
! call linspace(0.0_dp,1.0_dp,101,x,dx) ! subroutine version
! ... assemble the tridiagonal matrix and rhs, dx appears in the matrix entries ...
! ... solve system for field u using Thomas algorithm or gttrf and gttrs from LAPACK ...
call print_file("result.txt",x,u) But I can agree with the pure argument of @milancurcic . If the step size is added to the function prototype, then In the end, the user can always recover the step size as follows x = linspace(0.0_dp,1.0_dp,11)
dx = x(2)-x(1) which I suppose is easier to remember and more intuitive than a subroutine version... |
Indeed, I feel the second option: x = linspace(0.0_dp, 1.0_dp, 11)
dx = x(2)-x(1) is perhaps even clearer what it is doing, and it allows us to stay "pure". Matlab's linspace does not have this |
How would this module be called?
|
In
I feel "numerical" is too general. I would prefer something more concrete. I like "mesh" or "grid" so far the most. |
This comment has been minimized.
This comment has been minimized.
This has been implemented. |
The linspace API is implemented here: https://github.com/certik/fortran-utils/blob/b43bd24cd421509a5bc6d3b9c3eeae8ce856ed88/src/mesh.f90#L157
Matlab's linspace.
The logspace is similar, but I don't have it implemented yet -- historically I have used a function called meshexp, which is more general --- it allows you to change the gradation of the mesh, which the Matlab's logspace does not allow. The NumPy's logspace allows to set different
base
which allows to change gradation. So I think mymeshexp
can be implemented using NumPy'slogspace
. NumPy also has geomspace where you can specify the end points directly (just like in mymeshexp
) but it does not allow to change gradation. So I think there is room formeshexp
, perhaps we should change the name somehow to be consistent with the other functions.The text was updated successfully, but these errors were encountered: