Creating sparse diagonal matrix of CuArray

Hello everyone,

If we have a vector (u), we can easily convert it into a sparse diagonal matrix using the command spdiagm(u).

I want to do the same operation using CUDA where u is defined as CuArray(u). The command spdiagm(u) gives the scalar indexing error and therefore it does not work.

I tried using CuSparseMatrixCSC(Diagonal(u)), it works but it is very slow. Is there a way to perform this task efficiently?

I am relatively new to CUDA so any help is appreciated.

Thank you.