{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The user-defined "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "matvec",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": null,
                "version": null,
                "kind": "local",
                "path": "matvec"
              },
              "kind": "local"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " function must properly handle the case where "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "v"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " has shape "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "(N,)"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " as well as the "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "(N,1)"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " case.  The shape of the return type is handled internally by "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "LinearOperator",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.sparse.linalg._interface:LinearOperator"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "It is highly recommended to explicitly specify the "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "dtype",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": null,
                "version": null,
                "kind": "local",
                "path": "dtype"
              },
              "kind": "local"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", otherwise it is determined automatically at the cost of a single matvec application on "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "int8"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " zero vector using the promoted "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "dtype",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": null,
                "version": null,
                "kind": "local",
                "path": "dtype"
              },
              "kind": "local"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " of the output. Python "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "int"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " could be difficult to automatically cast to numpy integers in the definition of the "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "matvec",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": null,
                "version": null,
                "kind": "local",
                "path": "matvec"
              },
              "kind": "local"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " so the determination may be inaccurate. It is assumed that "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "matmat",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": null,
                "version": null,
                "kind": "local",
                "path": "matmat"
              },
              "kind": "local"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "rmatvec",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": null,
                "version": null,
                "kind": "local",
                "path": "rmatvec"
              },
              "kind": "local"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", and "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "rmatmat",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": null,
                "version": null,
                "kind": "local",
                "path": "rmatmat"
              },
              "kind": "local"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " would result in the same dtype of the output given an "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "int8"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " input as "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "matvec",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": null,
                "version": null,
                "kind": "local",
                "path": "matvec"
              },
              "kind": "local"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "LinearOperator instances can also be multiplied, added with each other and exponentiated, all lazily: the result of these operations is always a new, composite LinearOperator, that defers linear operations to the original operators and combines the results."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "More details regarding how to subclass a LinearOperator and several examples of concrete LinearOperator instances can be found in the external project "
            },
            {
              "__type": "Link",
              "__tag": 4049,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "PyLops"
                }
              ],
              "url": "https://pylops.readthedocs.io",
              "title": ""
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Raises": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Yields": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Methods": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Returns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Common interface for performing matrix vector products"
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Receives": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warnings": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Attributes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "args",
              "annotation": "tuple",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "For linear operators describing products etc. of other linear operators, the operands of the binary operation."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "ndim",
              "annotation": "int",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Number of dimensions (this is always 2)"
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "shape",
              "annotation": "tuple",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Matrix dimensions "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "(M, N)"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "matvec",
              "annotation": "callable f(v)",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Returns returns "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "A @ v"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "rmatvec",
              "annotation": "callable f(v)",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Returns "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "A^H @ v"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", where "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "A^H"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is the conjugate transpose of "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "A"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "matmat",
              "annotation": "callable f(V)",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Returns "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "A @ V"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", where "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "V"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is a dense matrix with dimensions "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "(N, K)"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "dtype",
              "annotation": "dtype",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Data type of the matrix."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "rmatmat",
              "annotation": "callable f(V)",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Returns "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "A^H @ V"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", where "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "V"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is a dense matrix with dimensions "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "(M, K)"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Many iterative methods (e.g. "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "cg",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.sparse.linalg._isolve.iterative:cg"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "gmres",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.sparse.linalg._isolve.iterative:gmres"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ") do not need to know the individual entries of a matrix to solve a linear system "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "A@x = b"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". Such solvers only require the computation of matrix vector products, "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "A@v"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " where "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "v"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is a dense vector.  This class serves as an abstract interface between iterative solvers and matrix-like objects."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "To construct a concrete "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "LinearOperator",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.sparse.linalg._interface:LinearOperator"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", either pass appropriate callables to the constructor of this class, or subclass it."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "A subclass must implement either one of the methods "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "_matvec"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "_matmat"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", and the attributes/properties "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "shape"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " (pair of integers) and "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "dtype"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " (may be None). It may call the "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "__init__"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " on this class to have these attributes validated. Implementing "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "_matvec"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " automatically implements "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "_matmat"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " (using a naive algorithm) and vice-versa."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Optionally, a subclass may implement "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "_rmatvec"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " or "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "_adjoint"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " to implement the Hermitian adjoint (conjugate transpose). As with "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "_matvec"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "_matmat"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", implementing either "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "_rmatvec"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " or "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "_adjoint"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " implements the other automatically. Implementing "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "_adjoint"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is preferable; "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "_rmatvec"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is mostly there for backwards compatibility."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Other Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    }
  },
  "_ordered_sections": [
    "Summary",
    "Extended Summary",
    "Parameters",
    "Attributes",
    "Methods",
    "Returns",
    "Yields",
    "Receives",
    "Other Parameters",
    "Raises",
    "Warns",
    "Warnings",
    "Notes"
  ],
  "item_file": "/scipy/sparse/linalg/_interface.py",
  "item_line": 56,
  "item_type": "class",
  "aliases": [
    "scipy.linalg._decomp_interpolative.LinearOperator"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import numpy as np\nfrom scipy.sparse.linalg import LinearOperator\ndef mv(v):\n    return np.array([2*v[0], 3*v[1]])\nA = LinearOperator((2,2), matvec=mv)\nA\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "A.matvec(np.ones(2))\nA @ np.ones(2)\n",
        "execution_status": "failure"
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "aslinearoperator",
        "reference": {
          "__type": "LocalRef",
          "__tag": 4022,
          "kind": "module",
          "path": "scipy.sparse.linalg._interface:aslinearoperator"
        },
        "kind": "module"
      },
      "descriptions": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Construct LinearOperators"
            }
          ]
        }
      ],
      "type": null
    }
  ],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "args",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "VAR_POSITIONAL",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "kwargs",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "VAR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "LinearOperator"
  },
  "references": null,
  "qa": "scipy.sparse.linalg._interface:LinearOperator",
  "arbitrary": [],
  "local_refs": [
    "args",
    "dtype",
    "matmat",
    "matvec",
    "ndim",
    "rmatmat",
    "rmatvec",
    "shape"
  ]
}