Memory-free multivariate polynomials

Thanks! This is very helpful. I would have had no idea how to construct a basis and use it.
If I compare the performance with EvalMultiPoly.jl using only orders up to 3, EvalMultiPoly.jl is significantly faster (81µs for order 3, compared to 2.8 ms for SmolyakParameters(2, 2)) but then this is not a fair comparison. However, with order 4 or more EvalMultiPoly.jl starts to allocate and then the performance get really bad.
If you can add a TensorBasis that would allow to create simple mutivariate polynomials similar to valMultiPoly.jl, this may be a nice addition!

2 Likes

… another thing is that linear_combination leads to a different way that the order of the multivariate polynomial is limited than one would typically limit the order in a multivariate expansion (e.g. yx^2 not being part of the second order multivariate polynomial, but x^2 being part of it). Any idea how to handle this?

Sorry for the late reply. The package implements the Smolyak sparse family, which has this property, and is generally considered to have some other nice ones.

If you want to include polynomials x_1^{n_1} x_2^{n_2} \dots such that \sum n_i \le K, that is a different family. I could add it if needed — I am currently refactoring the package. Note however that generally this family does not have the polynomial complexity of Smolyak, so you still get a mild curse of dimensionality. [I know that historically, it is widely used.]

Thanks. Sounds interesting to switch to this family of limited polynomials. Any progress on the TensorBasis?

I will be finishing the refactoring I am working on first, but then it should be trivial to add. One thing I am not sure about is how much unrolling and static code generation one wants to use: as opposed to Smolyak, tensor bases get large really fast so unrolling becomes a liability at very small dimensions.

I can still get allocation-free loops, just not unrolled. I am coding up a hybrid approach that switches between the two at some dimension.

What are your dimensions, ie degree of polynomial along each dimension, and the total number of dimensions? Is it 200^2 or something else?

1 Like

The degree of the polynomial is in practical situations very small. E.g. multivariate (2 dimensions X, Y) and 3 orders (e.g YX^2 being one of the highest order terms). So the number of dimensions is typically up to 3. Maybe in crazy cases 4. This polynomial is then applied to millions of coordinates to transform, but this has nothing to do with the dimensions of the polynomial. However allocation-free becomes very important upon application to millions of pixels or voxels.

2 Likes

Thanks, this was informative. This is the use case I am targeting with unrolling.

1 Like