I have a vector u, with elements u[1],u[2],...u[n].
I then have an expression with terms that are linear in u[1],u[2],...u[n].
How can I collect these terms and group them as coefficients of u[1],u[2],...,u[n] without me having to explicitly state what n is?
When the collecting is actually done, n will be known, but I want to keep n arbitrary up to that point, and so need a method that works whichever value of n I pick.
New Issue: Similar to the above, but now for an input n, I have n^2 variables uu[1,1],...uu[1,n],...,[n,1],...,uu[n,n]. I want to cllect terms according to these variables. I've tried doing what I did before, writing down Array[uu,{n+1,n+1}], but this isn't working.