Skip to main content

No project description provided

Project description


eMaTe is a python package implemented in tensorflow which the main goal is provide useful methods capable of estimate spectral densities and trace functions of large sparse matrices.

Kernel Polynomial Method (KPM)

The Kernel Polynomial Method can estimate the spectral density of large sparse Hermitan matrices with a computaional cost almost linear. This method combines three key ingredients, the Chebyshev expansion, the stochastic trace estimator and kernel smoothing.


import igraph as ig
import numpy as np
import scipy
from scipy.sparse

L_sparse = scipy.sparse.coo_matrix(L)
g = ig.Graph.Erdos_Renyi(3000, 3/3000)
W = np.array(g.get_adjacency().data, dtype=np.float64)
vals_laplacian = np.linalg.eigvals(L).real
L_sparse = scipy.sparse.coo_matrix(L)
from emate.hermitian import pykpm
num_moments = 50
num_vecs = 100
extra_points = 10
ek_laplacian, rho_laplacian = pykpm(L_sparse, num_moments, num_vecs, extra_points)

Stochastic Lanczos Quadrature (SLQ)

The problem of estimating the trace of matrix functions appears in applications ranging from machine learning and scientific computing, to computational biology.[2]


Computing the Estrada index

from emate.symmetric.slq import pyslq
import tensorflow as tf

def trace_function(eig_vals):
    return tf.exp(eig_vals)

num_vecs = 100
num_steps = 50
approximated_estrada_index, _ = pyslq(L_sparse, num_vecs, num_steps,  trace_function)
exact_estrada_index =  np.sum(np.exp(vals_laplacian))
approximated_estrada_index, exact_estrada_index

The above code returns

(3058.012, 3063.16457163222)

[1] Hutchinson, M. F. (1990). A stochastic estimator of the trace of the influence matrix for laplacian smoothing splines. Communications in Statistics-Simulation and Computation, 19(2), 433-450.

[2] Ubaru, S., Chen, J., & Saad, Y. (2017). Fast Estimation of tr(f(A)) via Stochastic Lanczos Quadrature. SIAM Journal on Matrix Analysis and Applications, 38(4), 1075-1099.


This work has been supported also by FAPESP grants 11/50761-2 and 2015/22308-2. Research carriedout using the computational resources of the Center forMathematical Sciences Applied to Industry (CeMEAI)funded by FAPESP (grant 2013/07375-0).

Project details

Release history Release notifications

This version


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for emate, version 1.0.2
Filename, size File type Python version Upload date Hashes
Filename, size emate-1.0.2.tar.gz (11.9 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page