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

SplineSparse documentation #55

Open
HugoLhuillier opened this issue Apr 15, 2020 · 1 comment
Open

SplineSparse documentation #55

HugoLhuillier opened this issue Apr 15, 2020 · 1 comment

Comments

@HugoLhuillier
Copy link

Dear Chase and Spencer,

First of all, thank you very much for the work you are doing on this package. It has greatly improved my academic productivity.
Would you have any documentation on the SplineSparse struct? How and when to use it? Playing a bit with your package, it seems that functions such as evalbase or row_kron are faster when dealing with SplineSparse, and I would like to take advantage of that.

PS: I realize that my question is very vague. I could try to make it more precise if that is helpful to you, but for the moment, any documentation would made me very content.

@sglyon
Copy link
Member

sglyon commented Aug 26, 2020

Hi @HugoLhuillier sorry for letting this sit so long.

Busy times!

The SplineSparse struct is something I created and haven't seen written up or documented anywhere.

The basic intuition is that for an order n spline approximation, each row of the basis matrix will be entirely zeros except for an n+1 set of contiguous columns. This means we can store the basis matrix by storing (n+1)*m values (where m is the number of rows) and m integers for which column is the first of the contiguous column range. Then when multiplying by a coefficient vector, we only need to do n+1 multiplications per row and sum the result.

If stored as a dense matrix we would do a full dot product with all the zero's from the basis matrix -- resulting in zero.

If stored as a standard sparse matrix, we wouldn't leverage the special structure of having only a contiguous range of columns and would suffer some "random access" indexing performance penalties

Things get a little more complicated in multiple dimensions -- for each dimension you end up with a contiguous range of non-zero columns. That is also handled here.

I realize that isn't very precise or detailed, but hopefully it gives some intuitions for what SplineSparse does and how it is implemented!

Thanks

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