Skip to content

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

@svaiter

Description

@svaiter

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions