-
Notifications
You must be signed in to change notification settings - Fork 534
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
Implement approx1 and approx2 along specified dimensions. #2297
Conversation
include/af/signal.h
Outdated
\param[in] offGrid is the value that will set in the output array when certain index is out of bounds | ||
\return the array with interpolated values | ||
\param[in] yi is the input array | ||
\param[in] xo array contains the interpolation locations |
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.
Not liking the x,y parameters. what does xo stand for? in and pos seem to make more sense.
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.
Modified.
ca167f2
to
2134d4d
Compare
docs/details/signal.dox
Outdated
@@ -211,54 +211,109 @@ respectively, then the possible batch operations are as follows. | |||
\defgroup signal_func_approx1 approx1 | |||
\ingroup approx_mat | |||
|
|||
approx1 interpolates data along a single dimension. | |||
approx1 interpolates data along one dimension. Interpolation computes | |||
for values of unknown points out of known ones. |
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.
Looks like a typo in second sentence. Just computes
instead of computes for
is sufficient.
Also, lets keep the first sentence short as that appears in the brief descriptions of the documentation. So, move this line into a separate line so that approx interpolates data along one dimension
comes in brief description.
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.
I agree with Pradeep on moving the second sentence to the next paragraph. That way too you can expand more on what interpolation means and not be restricted to keeping it short because it's part of the brief description. I mean, for me at least, the way you described interpolation works for extrapolation as well, so I think it needs a little more detail and so I think it should be moved after the first line/brief description I saw that you do describe interpolation in more detail below.
Maybe it would be helpful too if I review the docs as well, reading it from a newcomer's perspective. |
docs/details/signal.dox
Outdated
the `grid_beg` and `grid_step` arguments. | ||
|
||
The position array (<=1D), `pos`, contains a combination of known and | ||
unkown positions/indices on the interpolation grid. The position |
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.
Typo: "unkown". Also you already wrote "The position array, pos" above. Also why <=1D? Is it because pos
can be just a single index as well?
docs/details/signal.dox
Outdated
dimension in which the measurements will be made in the input array. | ||
|
||
Any unknown position/index values that lie within the interpolation | ||
grid range will be calculated for using interpolation. Unknown points |
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.
What if we replace "calculated for" with "determined" (and "computes for" with "determines" in the very first line)?
docs/details/signal.dox
Outdated
the `off_grid` value. Known points will be replaced with corresponding | ||
values from the input array. | ||
|
||
The interpolation dimension, `interp_dim`, is the leading dimension |
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.
I somehow feel like this description should be closer to the description of the pos
argument, since they both say something about the leading dimension. But I get it that the pos
array must be intended to be along the interp_dim
dimension, correct?
docs/details/signal.dox
Outdated
|
||
The multi-dimensional (>=1D) input array, `in`, contains known values | ||
to be used for interpolation. These known values lie on a 1D | ||
interpolation grid - a one-dimensional, uniformly-spaced grid of |
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.
I'm kind of getting confused on "1D interpolation grid". Did you mean "one dimensional" to describe the interpolation, and not the grid (the input array)?
docs/details/signal.dox
Outdated
equally spaced indices in the range of [0,n) can be achieved with grid | ||
begin and step values of 0 and 1, respectively. A standard uniform | ||
grid will be used in the case that the interpolating dimension as well | ||
as the grid start and step values are not passed in. |
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.
So I'm still not sure what grid_beg
and grid_step
are for, given that we have pos
already. Is grid_beg
where you start basing the interpolation on? Say I have a 1D input array with 100 elements that look like a piecewise function, where the first half [0, 50) looks like a quadratic function and the second half [50, 100) looks like a line, and I set pos
to be indices within the second half, and I don't want the first half to affect the interpolation - do I set grid_beg
then to be 50?
There, I just added comments on the |
docs/details/signal.dox
Outdated
locations. | ||
The input array, `in`, is comprised of values which lie on a range of | ||
indices defined by `idx_start` and `idx_step` [idx_start:idx_step:N] | ||
along dimension `interp_dim`. |
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.
Like you did below for off_grid
, we should also explain that the API of approx1 that doesn't take idx_start
and idx_step
assumes them to be of so and so values.
Similar, explanation for interp_dim
is also needed.
docs/details/signal.dox
Outdated
in the range [0, n) along each dimension. | ||
The positions are sampled with respect to data at these locations. | ||
approx2 interpolates data along two dimensions. Interpolation computes | ||
for values of unknown points out of known ones. |
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.
The second sentence is not needed, this makes the short description too long to appear in UI - check the very first sentence in this page. Also, you talk about what interpolation does below also. So, this is not needed here in my opinion.
docs/details/signal.dox
Outdated
|
||
Interpolation positions outside of the interpolation grid range are | ||
not extrapolated. Instead, those values default to `off_grid`, whose | ||
default value is 0. |
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.
Looks like last two paragraphs are giving out only redundant info that is already explained in earlier paragraphs.
See arrayfire/assets#7 for assets PR. Update: assets is merged now. |
@mlloreda I think it looks great and definitely much better what we had earlier. The docs job failed though. Looks like assets submodule isn't not updated to your new changes. |
9d93431
to
594de3a
Compare
Also updated API version guard.
Step size of zero generates an invalid sampling grid.
Also: - Removed unnecessary header includes from cpu/approx.cpp - Minor c/approx.cpp cleanup - Minor approx1/2 test cleanup
- Check for non-monotonic positions. - Check for approx behavior with af::Inf values.
Also referencing snippets from test framework.
The approx CPU kernel implementation was calling the interp() kernel with the incorrect dimension values. This was causing the CPPUniform{Row,Column}MajorInterpolation tests to fail previously. Also improved approx1 and approx2 tests.
All tests performing interpolation. Improved test names, removed unnecessary tests, reordered tests
New approx1/2 functions which allow the user to select which dimension(s) to interpolate across.
Documentation has been updated and new tests have been added to @pavanky's original #1990 PR.