-
Notifications
You must be signed in to change notification settings - Fork 170
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
First implementation of real-valued linspace. #420
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you and welcome!
A general comment: I wonder if such a procedure would find a better place in the module stdlib_linalg
.
In Matlab it is in the same section as eye
, diag
,....
Split linspace into "default" and "n" function calls to avoid use of allocatable array
Thank you @ejovo13!
There's also |
As per @milancurcic 's advice, I refactored the linspace interface and implementation under the |
Hello. I've implemented the functions logspace and lnspace, defined in submodules logspaceThe The various function signatures of logspace (and linspace) are staggered and not using optional parameters for two reasons. The first is that using the length this logspace implementation differs from MATLAB's because we can choose the base with which to generate the logarithmic space. lnspace
TestsRunning make test will check certain qualities about the results and will output a few select log files showing the arrays generated from their calls for manual inspection. Here is a gist that shows sample output. |
How about a similar function that returns points based on a geometric
series? Note: that would require an extra parameter - the ratio between
adjacent intervals.
Op di 1 jun. 2021 om 00:32 schreef Evan Voyles ***@***.***>:
… Hello. I've implemented the functions logspace and lnspace, defined in
submodules stdlib_math_logspace and stdlib_math_lnspace.
logspace
The logspace function mimicks the matlab implementation. The first two
parameters are used to build the range from base^start to base^end. When
base is not specified, use base 10. When the length, n, is not specified,
output a rank 1 array of 50 elements.
The various function signatures of logspace (and linspace) are staggered
and not using optional parameters for two reasons. The first is that using
the length n as an optional parameter forces us to use allocatable arrays
as our result, which should be avoided. Secondly, when using the base as an
optional argument, the generic procedure is unable to distinguish function
calls when the base is not passed.
this logspace implementation differs from MATLAB's because we can choose
the base with which to generate the logarithmic space.
lnspace
lnspace is a special case of logspace when the base is equal to Euler's
number e. Various levels of precision of EULERS_NUMBER are used in the
stdlib_math module.
Tests
Running make test will check certain qualities about the results and will
output a few select log files showing the arrays generated from their calls
for manual inspection. Here is a gist
<https://gist.github.com/ejovo13/c0ea7b4eefe97d1ddf0c485e8048cc20> that
shows sample output.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#420 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAN6YR7UMJI3SBHKBWWUF5LTQQFATANCNFSM452VE52A>
.
|
Co-authored-by: Jeremie Vandenplas <jeremie.vandenplas@gmail.com>
Co-authored-by: Jeremie Vandenplas <jeremie.vandenplas@gmail.com>
Co-authored-by: Jeremie Vandenplas <jeremie.vandenplas@gmail.com>
Co-authored-by: Jeremie Vandenplas <jeremie.vandenplas@gmail.com>
Co-authored-by: Jeremie Vandenplas <jeremie.vandenplas@gmail.com>
Demand a lower tolerance value for higher precision tests
Co-authored-by: Sebastian Ehlert <28669218+awvwgk@users.noreply.github.com>
Well, I believe that I've addressed, on my side, all of your comments. What I thought was going to be a quick and easy first PR has dragged on (not that that's a bad thing) and generated a lot of fruitful discussion. Thank you to everyone for their contributions and suggestions to improve this PR. Apart from a few unresolved discussions, I don't believe that there is anything left for me to do. The ball is in your court and I will wait for any further direction. Thank you all. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
I approve it, pending a few minor comments.
Regarding the checks, I would prefer checks on the absolute values, instead of on relative values. But I leave that for the next reviewer.
Co-authored-by: Jeremie Vandenplas <jeremie.vandenplas@gmail.com>
Co-authored-by: Jeremie Vandenplas <jeremie.vandenplas@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pending any unresolved requests, this looks ready to be part of stdlib. Thanks a lot for sharing this contribution.
Co-authored-by: Jeremie Vandenplas <jeremie.vandenplas@gmail.com>
Co-authored-by: Jeremie Vandenplas <jeremie.vandenplas@gmail.com>
Co-authored-by: Jeremie Vandenplas <jeremie.vandenplas@gmail.com>
@ivan-pi @milancurcic you commented this PR. Could you check if your comments were answered appropriately, and appove this PR if it is ok, please? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some details in the docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, great addition. I only left one nit-pick about labeled format
statements in test subroutines.
Hi all,
This is my first time contributing on any project, ever, so bear with me if I make any missteps. As per issue #17, there seems to be a demand to implement some simple functions that return a range of values.
So, I implemented
linspace
using MATLAB's syntax as a guide. Currently there is no support for passing complex values into the function but if this pull request gets approved I will implement it ASAP. This pull request is a gentle attempt to make my first contribution and to understand the ropes before I start trying to tackle other open issues.I didn't know how to implement a robust test for checking all of the elements in the returned rank 1 array, so I instead check the first and last values, and the length of the returned array in the
test_linspace.f90
test.Nevertheless, here is a quick demo when using the
linspace
function from another project which imports the fortran_stdlib: