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

Implement approx1 and approx2 along specified dimensions. #2297

Merged
merged 23 commits into from
Oct 20, 2018

Conversation

mlloreda
Copy link
Member

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.

include/af/signal.h Outdated Show resolved Hide resolved
\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
Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified.

@mlloreda mlloreda force-pushed the approx branch 3 times, most recently from ca167f2 to 2134d4d Compare October 4, 2018 14:25
@@ -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.
Copy link
Member

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.

Copy link
Contributor

@mark-poscablo mark-poscablo Oct 11, 2018

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.

@mark-poscablo
Copy link
Contributor

Maybe it would be helpful too if I review the docs as well, reading it from a newcomer's perspective.

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
Copy link
Contributor

@mark-poscablo mark-poscablo Oct 11, 2018

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?

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
Copy link
Contributor

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)?

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
Copy link
Contributor

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?


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
Copy link
Contributor

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)?

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.
Copy link
Contributor

@mark-poscablo mark-poscablo Oct 11, 2018

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?

@mark-poscablo
Copy link
Contributor

mark-poscablo commented Oct 11, 2018

There, I just added comments on the approx1 docs, at least. I think they're not showing up here in this page though since I chose "Add single comment", sorry, but please check out the "Files changed" tab They show up now, sorry, just had to refresh the page. In any case I appreciate adding more detail on the approx functions! I think the the current ones are too short to be really helpful.

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`.
Copy link
Member

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.

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.
Copy link
Member

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.


Interpolation positions outside of the interpolation grid range are
not extrapolated. Instead, those values default to `off_grid`, whose
default value is 0.
Copy link
Member

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.

@mlloreda
Copy link
Member Author

screen shot 2018-10-15 at 10 45 48 pm

screen shot 2018-10-15 at 10 46 05 pm

screen shot 2018-10-15 at 10 46 23 pm

screen shot 2018-10-15 at 10 46 38 pm

screen shot 2018-10-15 at 10 46 49 pm

@mlloreda
Copy link
Member Author

screen shot 2018-10-15 at 10 49 16 pm

screen shot 2018-10-15 at 10 49 39 pm

screen shot 2018-10-15 at 10 49 54 pm

screen shot 2018-10-15 at 10 50 11 pm

screen shot 2018-10-15 at 10 50 23 pm

@mlloreda
Copy link
Member Author

mlloreda commented Oct 16, 2018

See arrayfire/assets#7 for assets PR.

Update: assets is merged now.

@9prady9
Copy link
Member

9prady9 commented Oct 16, 2018

@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.

@mlloreda mlloreda force-pushed the approx branch 6 times, most recently from 9d93431 to 594de3a Compare October 16, 2018 14:15
pavanky and others added 17 commits October 16, 2018 09:17
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants