Skip to content

Commit 47b59fc

Browse files
Made LinearOperator independent of spLinearOperator (#482)
* Made LinearOperator independent of spLinearOperator * Added Docstrings * Updated _matvec and _rmatvec * Added and Updated _AdjointLinearOperator, _TransposeLinearOperator, _ProductLinearOperator * minor: fix some issues as documented in PR review This commit cleans up the linearoperator module, reducing the use of LinearOperator and aslinearoperator only to those cases where it is stricly needed - mostly to allow mix pylops and scipy operators as much as possible. * Added docs * bug: fix issue introduced in describe with new private classes in linearoperator * Removed docstrings * minor: small changes to doc" * minor: small change to LinearOperator docstring * minor: small change to LinearOperator docstring --------- Co-authored-by: mrava87 <[email protected]>
1 parent 3cf1601 commit 47b59fc

File tree

6 files changed

+273
-157
lines changed

6 files changed

+273
-157
lines changed

docs/source/adding.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ which will be used as *parent* class for any of our operators:
2323
2424
from pylops import LinearOperator
2525
26-
This class is a child of the
27-
:py:class:`scipy.sparse.linalg.LinearOperator` class itself which implements the same methods of its parent class
28-
as well as an additional method for quick inversion: such method can be easily accessed by using ``\`` between the
29-
operator and the data (e.g., ``A \ y``).
26+
This class was originally defined as a child of the :py:class:`scipy.sparse.linalg.LinearOperator`, implementing
27+
the same methods of its parent class as well as additional methods for quick inversion (e.g., ``A \ y``),
28+
eigenvalues computation, conversion to dense matrices, etc. From version ``v2.1`` onwards, our linear operator
29+
class has become stand-alone; however, by keeping the same naming structure of the original scipy class, we still
30+
allow inter-operability with scipy-native linear operators and solvers.
3031

3132
After that we define our new object:
3233

docs/source/index.rst

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ PyLops offers such solvers for many different types of problems, in particular l
1414
Get started by :ref:`installing PyLops <Installation>` and following our quick tour.
1515

1616

17-
1817
Terminology
1918
-----------
2019
A common *terminology* is used within the entire documentation of PyLops. Every linear operator and its application to
@@ -48,19 +47,22 @@ such as `Basic Earth Imaging <http://sepwww.stanford.edu/sep/prof/bei11.2010.pdf
4847

4948
Implementation
5049
--------------
51-
PyLops is build on top of the `scipy <http://www.scipy.org/scipylib/index.html>`_ class :py:class:`scipy.sparse.linalg.LinearOperator`.
50+
PyLops was originally build on top of the `scipy <http://www.scipy.org/scipylib/index.html>`_ class
51+
:py:class:`scipy.sparse.linalg.LinearOperator`. From version ``v2.1`` onwards, whilst still being heavily inspired
52+
by its scipy counterpart, PyLops's :py:class:`pylops.linearoperator.LinearOperator` has become a stand-alone class.
5253

53-
This class allows in fact for the creation of objects (or interfaces) for matrix-vector and matrix-matrix products
54+
This class allows for the creation of objects (or interfaces) for matrix-vector and matrix-matrix products
5455
that can ultimately be used to solve any inverse problem of the form :math:`\mathbf{y}=\mathbf{A}\mathbf{x}`.
5556

56-
As explained in the `scipy LinearOperator <https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.linalg.LinearOperator.html>`_
57-
official documentation, to construct a :py:class:`scipy.sparse.linalg.LinearOperator`, a user is required to pass appropriate callables
57+
To construct a :py:class:`pylops.linearoperator.LinearOperator`, a user is required to pass appropriate arguments
5858
to the constructor of this class, or subclass it. More specifically one of the methods ``_matvec`` and ``_matmat`` must be implemented for
5959
the *forward operator* and one of the methods ``_rmatvec`` or ``_adjoint`` may be implemented to apply the *Hermitian adjoint*.
60-
The attributes/properties ``shape`` (pair of integers) and ``dtype`` (may be None) must also be provided during ``__init__`` of this class.
60+
The attributes/properties ``dtype`` (may be None) and ``shape`` (pair of integers) -- or alternatively ``dims`` and ``dimsd`` --
61+
must also be provided during ``__init__`` of this class.
6162

6263
Any linear operator developed within the PyLops library follows this philosophy. As explained more in details in :ref:`addingoperator` section,
63-
a linear operator is created by subclassing the :py:class:`scipy.sparse.linalg.LinearOperator` class and ``_matvec`` and ``_rmatvec`` are implemented.
64+
a linear operator is created by subclassing the :py:class:`pylops.linearoperator.LinearOperator` class and implementing the
65+
``_matvec`` and ``_rmatvec``.
6466

6567

6668
History

0 commit comments

Comments
 (0)