dubfi.linalg.mpi_parent ======================= .. py:module:: dubfi.linalg.mpi_parent .. autoapi-nested-parse:: MPI linear algebra parent module. This module instructs multiple MPI processes (workers) to do linear algebra computations. .. codeauthor:: Valentin Bruch, DWD .. versionadded:: 0.1.0 (initial release) Classes ------- .. autoapisummary:: dubfi.linalg.mpi_parent.MpiContext dubfi.linalg.mpi_parent.MpiObj dubfi.linalg.mpi_parent.MpiVector dubfi.linalg.mpi_parent.MpiDenseBdMatrix dubfi.linalg.mpi_parent.MpiLinParamVector dubfi.linalg.mpi_parent.MpiDensePostR Functions --------- .. autoapisummary:: dubfi.linalg.mpi_parent.simple_segments dubfi.linalg.mpi_parent._send_array Module Contents --------------- .. py:class:: MpiContext Singleton class keeping information about MPI setup. Return singleton when trying to create new instance. .. py:method:: setup(workers = -1) Create MPI setup, create child process if necessary. .. py:method:: is_initialized() Check whether self has been initialized. .. py:method:: init(workers = -1) Initialize self if it is not initialized yet. .. py:property:: workers :type: int Number of MPI workers. .. py:property:: root :type: int Number (id) of MPI root (or parent) process. .. py:property:: iter Iterator over ids of worker processes. .. py:property:: comm MPI communicator. .. py:method:: gen_name(prefix = '') Generate a new, unique name. .. py:method:: send_cmd(command) Send command to worker processes. .. py:method:: quit() Send termination signal to MPI child processes. .. py:method:: __del__() Destructor: quit child processes. .. py:method:: Reduce(recvbuf, op) Wrap :meth:`mpi4py.MPI.Comm.Reduce` to receive data in root. .. py:function:: simple_segments(size, overlap, number = -1) Construct MPI segments along one linear, equally spaced coordinate. .. py:function:: _send_array(array) Broadcast array to all child processes. .. py:class:: MpiObj Base class for all MPI parent objects. Initialization generates self._name and destruction deletes the associated objects on worker processes. .. py:method:: __del__() Destructor: Delete associated objects on worker processes. .. py:class:: MpiVector(seg, shape) Bases: :py:obj:`dubfi.linalg.types.AbstractVector`, :py:obj:`MpiObj` MPI distributed vector. .. py:property:: shape Shape of array representation of self, last dimension is the vector dimension. .. py:property:: data Numpy array representation of self, collects data from worker processes. .. py:method:: fromdata(data, other=None) :classmethod: Construct distributed vector from dense array, borrowing segment information from other. .. py:method:: fromarray(segments, data) :classmethod: Construct distributed vector from dense array and given segments. .. py:method:: apply(other) Compute scalar product with other vector. .. py:method:: dot(other) Compute scalar product along some non-vector dimension. .. py:method:: __add__(other) Add two vectors, applying broadcasting rules. .. py:method:: __iadd__(other) Add vector in-place. .. py:method:: __sub__(other) Subtract vector from self, applying broadcasting rules. .. py:method:: __isub__(other) Subtract vector in-place. .. py:method:: __mul__(other) Multiply by scalar or numpy array treated as scalar along vector space dimension. .. py:method:: iszero() Check if all elements are zero. .. py:method:: tonumpy() Numpy array representation of self, collects data from worker processes. .. py:class:: MpiDenseBdMatrix(seg, shape) Bases: :py:obj:`dubfi.linalg.types.AbstractOperator`, :py:obj:`MpiObj` MPI parent of approximately diagonal or block-diagonal matrix. .. py:property:: shape Shape of array (matrix) representation of self. .. py:method:: fromarray(data, seg) :classmethod: Construct distributed operator from dense array and given segments. .. py:method:: apply(vec) Apply operator on vector: self @ vec. .. py:method:: rapply(vec) Apply transpose operator on vector: self.T @ vec. .. py:method:: inv() Compute (multiplicative) inverse operator. .. py:method:: solve(vec) Solve linear equation self @ x = vec for x. .. py:method:: chain(other) Combine operators: self @ other. .. py:method:: diagonal() Return diagonal of self as MPI vector. .. py:method:: __mul__(other) Multiply element-wise. .. py:method:: __add__(other) Add to other linear operator. .. py:method:: __iadd__(other) Add other linear operator in-place. .. py:method:: __sub__(other) Subtract other linear operator. .. py:method:: __isub__(other) Subtract other linear operator in-place. .. py:method:: dot(other) Inner product along non-vector dimensions. .. py:method:: trace() Compute trace of self. .. py:method:: trace_product(other) Compute trace of (self @ other). .. py:method:: logdet() Compute log(det(self)) assuming that self is a positive definite, real-symmetric matrix. .. py:method:: tonumpy() Numpy array representation of self, collects data from worker processes. .. py:method:: sandwich(vec) Compute vec @ self @ vec. .. py:class:: MpiLinParamVector(seg, shape) Bases: :py:obj:`dubfi.linalg.generic.ParametrizedVector`, :py:obj:`MpiObj` MPI distributed linear parametrized vector. .. py:method:: fromarray(seg, array) :classmethod: Construct distributed parametrized vector from dense array and given segments. .. py:method:: __call__(s) Compute vector at given parameters. .. py:method:: grad(s) Compute gradient of vector at given parameters. .. py:method:: hess(s) Compute Hesse matrix of vector at given parameters. .. py:class:: MpiDensePostR(seg) Bases: :py:obj:`dubfi.linalg.generic.ParametrizedOperator`, :py:obj:`MpiObj` MPI distributed R matrix for flux inversion. .. py:method:: fromarray(seg, h_ens, localization_length, regularization) :classmethod: Construct distributed object from dense vectors and given segments. .. py:method:: __call__(s) Compute R at given parameters. .. py:method:: grad(s) Compute gradient of R at given parameters. .. py:method:: hess(s) Compute Hesse matrix of R at given parameters.