benchopt / benchmark_tv_1d

TV Denoising in 1D
2 stars 7 forks source link

Efficient implementation of D x / D.T @ v #13

Open svaiter opened 2 years ago

svaiter commented 2 years ago

In several solvers, sparse matrix is used to implement the finite difference operator as

len_y = len(self.y)
data = np.array([np.ones(len_y), -np.ones(len_y)])
diags = np.array([0, 1])
D = spdiags(data, diags, len_y-1, len_y)

I believe it could be implemented with a forward operator np.diff and an adjoint -np.diff(x, append=0, preprend=0) A quick profiling give me x2 - x3 speedup, but most importantly it generalizes better if one wants to do 2D.

EnLAI111 commented 2 years ago

Thanks! I will change them.

todo for me: