campospinto / psydac_dev

Python 3 library for isogeometric analysis
https://pyccel.github.io/psydac/
MIT License
0 stars 0 forks source link

Matrix-Free Linear Operator #7

Closed e-moral-sanchez closed 3 months ago

e-moral-sanchez commented 4 months ago

This PR provides a MatrixFreeLinearOperator class which is a subclass of the abstract class LinearOperator.

The new class allows to create a general matrix-free linear operator. The constructor only requires the domain, codomain and a callable dot method.

Notes:

Additional change:

campospinto commented 4 months ago

This is useful I think, thanks!

As a test, you can check the behaviour of a "fake" matrix-free operator: an operator created with a dot product involving a Stencil Matrix should act exactly like the matrix itself.

You can also check that an iterative solver (like cg) can run with an object of this new class.

campospinto commented 4 months ago

I see that some tests are failing because of minres() getting an unexpected keyword argument tol. Is this related to this new class?

e-moral-sanchez commented 3 months ago

The new version 1.14.0 of SciPy removed the tol argument in minres: https://docs.scipy.org/doc/scipy-1.13.1/reference/generated/scipy.sparse.linalg.minres.html

This also affects PR https://github.com/campospinto/psydac_dev/pull/6 .

I will fix this in this PR.

campospinto commented 3 months ago

This PR provides the class MatrixFreeLinearOperator, which is a subclass of the abstract class LinearOperator.

The class MatrixFreeLinearOperator allows to create a general matrix-free linear operator. The constructor only requires the domain, codomain and a callable dot method.

TODO: add simple unit tests (ideas are welcome!)

I am just adding a few unit tests

campospinto commented 3 months ago

I am also adding some features to handle the case where the given dot method has not optional 'out' argument, and the possibility (not mandatory) to pass a 'transpose_dot' method