Skip to content

Commit c69aeec

Browse files
committed
add cupy example
1 parent aca5348 commit c69aeec

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

README.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ![eMaTe](emate.png)
22

3-
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.
3+
eMaTe it is a python package which the main goal is to provide methods capable of estimating the spectral densities and trace functions of large sparse matrices.
44

55
## Install
66
```
@@ -26,15 +26,15 @@ vals = np.linalg.eigvalsh(W).real
2626
```
2727

2828
```python
29-
from emate.hermitian import pykpm
29+
from emate.hermitian import tfkpm
3030
from stdog.utils.misc import ig2sparse
3131

3232
W = ig2sparse(G)
3333

34-
num_moments = 300
35-
num_vecs = 200
34+
num_moments = 100
35+
num_vecs = 100
3636
extra_points = 10
37-
ek, rho = pykpm(W, num_moments, num_vecs, extra_points)
37+
ek, rho = tfkpm(W, num_moments, num_vecs, extra_points)
3838
```
3939

4040
```python
@@ -43,6 +43,21 @@ plt.hist(vals, density=True, bins=100, alpha=.9, color="steelblue")
4343
plt.scatter(ek, rho, c="tomato", zorder=999, alpha=0.9, marker="d")
4444

4545
```
46+
If the CUPY pkg it is available in your machine you also can use the cupy implementation. When compared with the tf-kpm the
47+
The cupy-kpm it's more slow for median matrices and more faster for larger matrices
48+
49+
If the CUPY package it is available in your machine, you can also use the cupy implementation. When compared to tf-kpm, the
50+
Cupy-kpm is slower for median matrices (100k) and faster for larger matrices (> 10^6). The main reason it's because the tf-kpm was implemented in order to calc all te moments in a single step.
51+
52+
```python
53+
from emate.hermitian import cupykpm
54+
55+
num_moments = 100
56+
num_vecs = 100
57+
extra_points = 10
58+
ek, rho = cupykpm(W, num_moments, num_vecs, extra_points)
59+
```
60+
4661

4762
![](docs/source/imgs/kpm.png)
4863

0 commit comments

Comments
 (0)