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

1d transforms with multi-dimensional regions are slow #206

Closed
MikaelSlevinsky opened this issue Mar 27, 2023 · 3 comments · Fixed by #208
Closed

1d transforms with multi-dimensional regions are slow #206

MikaelSlevinsky opened this issue Mar 27, 2023 · 3 comments · Fixed by #208

Comments

@MikaelSlevinsky
Copy link
Member

Using the v0.15 default, I'm getting:

julia> using FastTransforms, LinearAlgebra

julia> X = randn(1024, 1024);

julia> @time leg2cheb(X);
  4.387465 seconds (218 allocations: 3.476 GiB, 4.53% gc time)

julia> @time leg2cheb(X);
  3.772526 seconds (218 allocations: 3.476 GiB, 5.03% gc time)

Is this defaulting to Toeplitz-dot-Hankel?
This is equivalent to the library call (plans included):

julia> @time begin
           p = plan_leg2cheb(X)
           lmul!(p, Matrix(lmul!(p, Matrix(X'))'))
       end;
  0.069058 seconds (7 allocations: 16.000 MiB)

julia> @time begin
           p = plan_leg2cheb(X)
           lmul!(p, Matrix(lmul!(p, Matrix(X'))'))
       end;
  0.071369 seconds (7 allocations: 16.000 MiB)

@dlfivefifty

@MikaelSlevinsky
Copy link
Member Author

Moreover, the partial interface change was bad because now similar functions don't behave similarly:

julia> jac2jac(X, 0, 0, -0.5, -0.5)[:,2] == jac2jac(X[:,2], 0, 0, -0.5, -0.5)
true

julia> leg2cheb(X)[:,2] == leg2cheb(X[:,2])
false

@dlfivefifty
Copy link
Member

We could change it to use lib_leg2cheb if the dimensions are very small. But when the dimensions are large the plan_leg2cheb is so slow its unusable:

julia> n = 100_000; x = randn(n); @time cheb2leg(x);
  1.184869 seconds (50.38 k allocations: 74.845 GiB, 22.38% gc time, 5.08% compilation time)

julia> n = 100_000; x = randn(n); @time (p = plan_cheb2leg(x); p*x)
 44.783364 seconds (53.23 k allocations: 3.302 MiB, 0.06% compilation time)

@dlfivefifty
Copy link
Member

Maybe for now with matrices we default to libfasttransforms since we aren't going to make it to n = 100k and leave the 1D transforms as Toeplitz dot Hankel?

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 a pull request may close this issue.

2 participants