Conversation
* Add support for rng and eltype in rand_itn * Bump ITN version * added error catching for gridpoints and function for random gridpoint sampling * change to overload Random.rand * Rename to prevent dimension overload * Rename calculate_fx(yz) to evaluate * Rename calculate_x(yz) to calculate_p * Rename delta_x(yz) to delta_p * created improved grid_points() * grid_points can take arbitrary ranges * Return dimension_indices * Changed instances of dimension in grid_points() and rand() to use d instead * updated grid_points() and rand() to incorporate feedback * grid_points() uses simpler method when span is default * changed to rand_p() and added enforced points * fix minor edge case * Formatting --------- Co-authored-by: Ryan Levy <rlevy@flatironinstitute.org> Co-authored-by: Joseph Tindall <51231103+JoeyT1994@users.noreply.github.com>
Add RNG passing
* Add support for rng and eltype in rand_itn * Bump ITN version * Rename to prevent dimension overload * Rename calculate_fx(yz) to evaluate * Rename calculate_x(yz) to calculate_p * Rename delta_x(yz) to delta_p * Return dimension_indices * add 1d polynomial interpolation * added black box function ITNs for fourier/chebyshev * working chebyshev * experimenting with function_itn * add data_itensornetwork() * started 2D functions, expanded data into QTT * working 2D function TNs * 2D data to ITN * clean up code * rename examples and add image to ITN example * function/data itn now takes top coefficients by magnitude by default * formatting * add data_itn documentation * move interpolation functions to new file * add compat version info --------- Co-authored-by: Ryan Levy <rlevy@flatironinstitute.org> Co-authored-by: Joseph Tindall <51231103+JoeyT1994@users.noreply.github.com>
* added clenshaw interpolation * update how max_coeffs works * add attribution and rename vars
…eaned up code a bit
… rand_p robust to big L
ryanlevy
left a comment
There was a problem hiding this comment.
Thanks Ryan!
I think the biggest change here is that rand_p changes the return value from Float to BigFloat. I have some concerns with this:
- I'm not sure we have tightened up passing
Numbereverywhere (we could maybe just have a test that we can evaluate a basic function on a grid or something) - grid_points doesn't match this behavior (basically everywhere just does base^L).
- I'm also not sure we want to enforce BigInt/BigFloat for say
L=4. We could disbatch on havingbasebe BigInt and force the user to deal with this, but I'm not 100% on this at the moment
For performance reasons I previously swapped index_value_to_scalar to return float(base)^L instead of base^L, but that won't work here due to InexactErrors. We could try to reconcile these choices though
@JoeyT1994 what do you think?
There was a problem hiding this comment.
I think we should also add support for multidimensional grid points.
Like we have a function where we pass a vector of dimensions and then zip up the result of grid_points called on each of the dimensions
There was a problem hiding this comment.
could you elaborate more on what your idea for this would look like?
for example, if you passed in a vector dimensions = [1,3], and suppose that grid_points(s,1) = [0, 1] and grid_points(s,3) = [0.3, 0.4, 0.5], would grid_points(s, [1, 3]) then be something like [[0, 0.3], [0, 0.4], [0, 0.5], [1, 0.3], [1, 0.4], [1, 0.5]]?
There was a problem hiding this comment.
Yes so if for each dimension I you input you generate some vector of Ni points then it would return the iterative product which consists of every unique combination of points:
e.g. [0.25, 0.5], [0.625, 0.975, 0.9875] -> [(0.25, 0.625), (0.25, 0.975),(0.25, 0.9875), (0.5, 0.625), (0.5, 0.975), (0.5, 0.9875)]
There was a problem hiding this comment.
would it be better to return an array of tuples or an array of arrays here?
I initially leaned towards having an array of arrays because evaluate takes in an array to specify the point it should evaluate the function at.
JoeyT1994
left a comment
There was a problem hiding this comment.
Thanks Ryan! I think we're getting there
|
For now, to deal with the BigFloat issue, I made it such that it only uses |
src/IndexMaps/realindexmap.jl
Outdated
| end | ||
|
|
||
| function round_to_nearest_exact_point(point::Number, L::Int) | ||
| return round(point * 2.0^min(63, L)) / 2.0^min(63, L) |
There was a problem hiding this comment.
This assumes base 2, but we shouldnt right? However, for base 2 we can use a trick
round(ldexp(point,L))/2.0^LThat seems to work for any L that can be represented by point.
There was a problem hiding this comment.
Good point, I generalized this function to take in the base as an argument
|
Thanks Ryan, maybe hold off until Joey can comment, but could you specialize anything with |
|
Thanks Ryan! This looks nearly there. I think the biggest change I would say we should do is to generate the random numbers in a way that avoids the The easiest way to do that is to generate a random bit string of length which now relies on negative powers which |
|
Quick comment, a better way to do the sum that reduces allocations is decimal = sum(((i, b),) -> b * ((base * 1.0)^-i), enumerate(bitstring))" |
|
thanks! @JoeyT1994 @ryanlevy made a quick fix |
This PR contains only the grid_points and rand_p related changes.