# Laguerre polynomials on GPU

**URL:** <https://discourse.julialang.org/t/laguerre-polynomials-on-gpu/99571>\
**Category:** GPU\
**Tags:** gpu, cuda, polynomials\
**Created:** [May 29, 2023, 3:42pm UTC](https://discourse.julialang.org/t/laguerre-polynomials-on-gpu/99571 "2023-05-29T15:42:54Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![albertomercurio](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/albertomercurio/32/27051_2.png) [@albertomercurio](https://discourse.julialang.org/u/albertomercurio)\
**Post date:** [May 30, 2023, 7:20am UTC](https://discourse.julialang.org/t/laguerre-polynomials-on-gpu/99571/5 "2023-05-30T07:20:00Z")

</div>

I tried to use the following recursive function

```julia
function gen_laguerre(n::Integer, alpha::Number, x::T)::T where T <: BlasFloat
    n == 0 && return 1
    n == 1 && return 1 + alpha - x
    return ((2*n-1+alpha-x)*gen_laguerre(n-1,alpha,x)-(n-1+alpha)*gen_laguerre(n-2,alpha,x))/n
end

```

but, as discussed [here](https://discourse.julialang.org/t/illegal-memory-indexing-for-broadcast-of-a-recursive-function/99534/1), it returns illegal memory indexing when using the GPU. Moreover, trying it with che CPU, I noticed that it is very slow compared to the HypergeometricFunctions.jl solution.

---

_[View the full topic](https://discourse.julialang.org/t/laguerre-polynomials-on-gpu/99571)._
