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

Why are coefficients in tensor product bases represented the way they are? #86

Open
Luapulu opened this issue Oct 5, 2021 · 1 comment

Comments

@Luapulu
Copy link

Luapulu commented Oct 5, 2021

If you have a basis of Chebyshev Polynomials, for example, that looks like this:

[T00 T01 T02;
 T10 T11  0 ;
 T20  0   0 ]

These are stored like so

[T00, T01, T10, T02, T11, T20]

My question is: why? Would it not be more natural to simply keep using the matrix? Or perhaps reshape the matrix to a vector, so columns are concatenated together?

In my case, using the matrix directly means I don't have a differentiation operator with 1e12 entries, but rather one with 1e6 entries, which is the difference between feasible and impossible. (The reduction occurs because in the matrix way of doing things, I can use the 1D operators on each column/row, which amounts to a simple matrix matrix multiplication).

Of course, this comes at the cost of doubling the memory, but it seems more than worth it to double the memory at this stage if you can save many orders of magnitude in memory/time when building operators and applying them.

@Luapulu Luapulu changed the title Why are coefficients in tensor product bases represented in the way they are? Why are coefficients in tensor product bases represented the way they are? Oct 5, 2021
@dlfivefifty
Copy link
Member

It's because for adaptively inverting operators it's more natural to order by polynomial degree.

Note there's ProductFun to partially support the matrix-of-coefficients way of thinking. There is old code for inversion for rank-2 PDEs:

https://github.com/JuliaApproximation/PDESchurFactorization.jl

ClassicalOrthogonalPolynomials.jl will eventually have better support for working with matrix of coefficients. But for now I'd suggest doing it by hand.

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

No branches or pull requests

2 participants