networksns.centrality_measures.exponential_quadrature¶
- networksns.centrality_measures.exponential_quadrature(A, u, v, tol=1e-07, maxit=50)¶
Computes \(q=u^T e^A v\). For the computation the polarization rule and Lanczos iteration are used [1].
- Parameters:
A (array_like) – sparse/dense symmetric matrix.
u (array) – vector.
v (array) – vector.
tol (float,optional) – tolerance for convergence, relative accuracy, default: 1e-7.
maxit (integer, optional) – maximum number of Lanczos iterations, default: 50.
- Returns:
q: (float) value of the bilinear form \(u^Te^Av\).
Examples
>>> from networksns import centrality_measures as cm >>> import numpy as np
Create symmetric matrix \(A\)
>>> A = np.arange(0, 9, 1) >>> A = A.reshape(3, 3) >>> A = A + A.transpose() array([[ 0, 4, 8], [ 4, 8, 12], [ 8, 12, 16]])
Create vectors \(u\) and \(v\)
>>> u = np.arange(0, 3) array([0, 1, 2]) >>> v = np.array([2,5,2]) array([2, 5, 2])
Compute \(q=u^T e^A v\)
>>> q = cm.exponential_quadrature(A, u, v)
References