tempnet.parallel_expm#

# # flow stability # # Copyright (C) 2021 Alexandre Bovet <alexandre.bovet@maths.ox.ac.uk> # # This program is free software; you can redistribute it and/or modify it under # the terms of the GNU Lesser General Public License as published by the Free # Software Foundation; either version 3 of the License, or (at your option) any # later version. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # details. # # You should have received a copy of the GNU Lesser General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>.

Attributes#

Functions#

compute_parallel_expm(A[, nproc, thresh_ratio, ...])

Computes the exponential matrix of A by computing each column separately

compute_subspace_expm_parallel(A[, n_comp, ...])

Compute the exponential matrix of A by applying expm on each connected

Module Contents#

tempnet.parallel_expm.compute_parallel_expm(A, nproc=1, thresh_ratio=None, normalize_rows=True, verbose=True)[source]#

Computes the exponential matrix of A by computing each column separately exploiting the fact that the column i of expm(A) is expm_multiply(A,delta_i) where delta i is the vector with zeros everywhere except on i. This only works if A is equal to (minus) a Laplacian matrix

Parameters:
  • A (scipy csc sparse matrix) – Square csc sparse matrix representing (+ or -) a Laplacian. If A is not csc, it will be converted to csc format.

  • nproc (int, optional) – number of parallel processes. The default is 1.

  • thresh_ratio (float, optional.) – Threshold ratio used to trim negligible values in the resulting matrix. For each columns c, values smaller than max(c)/thresh_ratio are set to zero. Default is None.

  • normalize_rows (bool, optional.) – Whether rows of the resulting matrix are normalized to sum to 1.

Returns:

scipy csr sparse matrix

Return type:

expm(A).

tempnet.parallel_expm.compute_subspace_expm_parallel(A, n_comp=None, comp_labels=None, verbose=False, nproc=1, thresh_ratio=None, normalize_rows=True)[source]#

Compute the exponential matrix of A by applying expm on each connected subgraphs defined by A and recomposing it to return expm(A). Small subgraphs are computed in parallel, each using scipy expm, and large subgraphs are computed with compute_parallel_expm.

Parameters:

A (scipy.sparse.csc_matrix)

nprocint, optional

number of parallel processes. The default is 1.

thresh_ratio: float, optional.

Threshold ratio used to trim negligible values in the resulting matrix. Values smaller than max(expm(A))/thresh_ratio are set to zero. Default is None.

normalize_rows: bool, optional.

Whether rows of the resulting matrix are normalized to sum to 1.

Returns:

  • expm(A) (scipy.sparse.csr_matrix)

  • matrix exponential of A

tempnet.parallel_expm.var_dict#