4 files were added to this release more than 14 days after its initial publication. Inspect the release files before installing.
PyRSB
librsb is a high performance sparse matrix library implementing the Recursive Sparse Blocks format, which is especially well suited for multiplications in iterative methods on very large sparse matrices.
PyRSB is a Cython-based Python interface to librsb.
On multicore machines, PyRSB can be several times faster than e.g. scipy.sparse.csr_matrix().
For an example how to invoke it with minimal overhead, see the advanced example.
So far, PyRSB is a prototype tested on Linux only. The librsb library instead is mature and well tested. Prospective PyRSB users and collaborators are welcome to contact me.
Features
The following functionality is implemented:
- Initialization with
rsb.rsb_matrix()styled asscipy.sparse.csr_matrix(). - Conversion from
scipy.sparse.csr_matrix(). - Multiplication by vector/multivector.
- Rows/columns through
nr=a.shape()[0]/nr=a.shape()[1], ornr()/nc(). find(),find_block(),tril(),triu(),shape(),nnz.print'able.- PyRSB-Specific:
autotune(),do_print(). - load from a Matrix Market file, e.g.
rsb_matrix(bytes(filename,encoding='utf-8'))
Build and Use
- If you want the
Makefileto build librsb (in this directory):make all-localwill attempt downloading librsb-1.2.0.9 from the web and building it here before building pyrsb. If the file is in place, it won't download it a second time. After that,make local-librsb-pyrsb(ormake lp) will build pyrsb using local librsb, then run it. This method shall use the best compilation flags. - If you have librsb already installed:
makeshall build and test. - Make sure you have
cython,scipy,numpy. installed. - If you don't have librsb installed you may want to try via pip
pip install pyrsb - If you want to install librsb on Ubuntu or Debian:
sudo apt-get install librsb-devshall suffice. Other operating systems have librsb, too. Please check yours. Or check librsb's web site. make testwill test benchmark code usingtest.py(to compare speed to SciPy)make bwill also produce graphs (requiresgnuplot)
Example Usage
# Example: demo1.py
"""
pyrsb demo
"""
import numpy
import scipy
from scipy.sparse import csr_matrix
from pyrsb import *
V = [11.0, 12.0, 22.0]
I = [0, 0, 1]
J = [0, 1, 1]
c = csr_matrix((V, (I, J)))
print(c)
# several constructor forms, as with csr_matrix:
a = rsb_matrix((V, (I, J)))
a = rsb_matrix((V, (I, J)), [3, 3])
a = rsb_matrix((V, (I, J)), sym="S") # symmetric example
print(a)
a = rsb_matrix((4, 4))
a = rsb_matrix(c)
nrhs = 1 # set to nrhs>1 to multiply by multiple vectors at once
nr = a.shape[0]
nc = a.shape[1]
order = "F"
x = numpy.empty([nc, nrhs], dtype=rsb_dtype, order=order)
y = numpy.empty([nr, nrhs], dtype=rsb_dtype, order=order)
x[:, :] = 1.0
y[:, :] = 0.0
print(a)
print(x)
print(y)
# import rsb # import operators
# a.autotune() # makes only sense for large matrices
y = y + a * x
# equivalent to y=y+c*x
print(y)
del a
Example Advanced Usage
# Example: demo2.py
"""
pyrsb demo
"""
import numpy
import scipy
from scipy.sparse import csr_matrix
from pyrsb import *
V = [11.0, 12.0, 22.0]
I = [0, 0, 1]
J = [0, 1, 1]
a = rsb_matrix((V, (I, J)))
nrhs = 4 # set to nrhs>1 to multiply by multiple vectors at once
nr = a.shape[0]
nc = a.shape[1]
# Choose Fortran or "by columns" order here.
order = "F"
x = numpy.empty([nc, nrhs], dtype=rsb_dtype, order=order)
y = numpy.empty([nr, nrhs], dtype=rsb_dtype, order=order)
x[:, :] = 1.0
y[:, :] = 0.0
print(a)
print(x)
print(y)
# Autotuning example: use it if you need many multiplication iterations on huge matrices (>>1e6 nonzeroes).
# Here general (nrhs=1) case:
a.autotune()
# Here with all the autotuning parameters specified:
a.autotune(1.0,0,1,2.0,ord('N'),1.0,nrhs,ord('F'),1.0,False)
# Inefficient: reallocate y
y = y + a * x
# Inefficient: reallocate y
y += a * x
# Equivalent but more efficient: don't reallocate y
a._spmm(x,y)
print(y)
del a
License
GPLv3+
Release files for pyrsb 0.2.20210303
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Files added late
4 files were uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release files before installing.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyrsb-0.2.20210303.tar.gz | 16.4 kB | Details |
Built distributions (wheels)
Total release size: 38.9 MB
Release files / pyrsb-0.2.20210303.tar.gz
| Download URL | pyrsb-0.2.20210303.tar.gz |
|---|---|
| Size | 16.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2a181f63a73289973b57c4d9864655f85a3d04ef0173e7f80be0a07bd5ef332b
|
|
BLAKE2b-256 checksum How to use checksums |
50db47075b7acaaf739c55afb2726627fd5c696a5711e9877484c0d7e5d31a05
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.2
|
Release files / pyrsb-0.2.20210303-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
File added late
This file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release file before installing.
| Download URL | pyrsb-0.2.20210303-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl |
|---|---|
| Size | 6.1 MB |
| Tags | CPython 3.9 Linux glibc 2.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
208f21c8dc273dfb4702a5fab52736727d4849d5a4d218d1860d7643e55c528c
|
|
BLAKE2b-256 checksum How to use checksums |
e8f043f2a0ad65707986d5e72d7e09e5b8beafa1c01e7d18d33a759e56c6d138
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.2
|
Release files / pyrsb-0.2.20210303-cp39-cp39-manylinux2010_x86_64.whl
| Download URL | pyrsb-0.2.20210303-cp39-cp39-manylinux2010_x86_64.whl |
|---|---|
| Size | 3.7 MB |
| Tags | CPython 3.9 Linux glibc 2.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
87951745a7e844144a50bc8bcecfcaf01e9044e7513452b3fea18162a8d33cfa
|
|
BLAKE2b-256 checksum How to use checksums |
aea30ae440029c96732f7683d558927e3400ebcc2f1bac1fa43abdb0a5a0e1e8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.2
|
Release files / pyrsb-0.2.20210303-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
File added late
This file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release file before installing.
| Download URL | pyrsb-0.2.20210303-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl |
|---|---|
| Size | 6.2 MB |
| Tags | CPython 3.8 Linux glibc 2.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
e382bd1391eac25fb0ba82a7697f139dd24707db7493a4589273aa72a28290b6
|
|
BLAKE2b-256 checksum How to use checksums |
1589e57bd837ae328b71b04626905ad2edbc2565d7e5fed2ef7eed93329e0188
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.2
|
Release files / pyrsb-0.2.20210303-cp38-cp38-manylinux2010_x86_64.whl
| Download URL | pyrsb-0.2.20210303-cp38-cp38-manylinux2010_x86_64.whl |
|---|---|
| Size | 3.8 MB |
| Tags | CPython 3.8 Linux glibc 2.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
5b444b249230e190ed7534c6c3c4e18581d8e1370ac0b710857cbe5b5b907468
|
|
BLAKE2b-256 checksum How to use checksums |
d32a4fec33ed19fa2e8c55d4df065f8b20cbc6560cc53f18f9587408caa976e9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.2
|
Release files / pyrsb-0.2.20210303-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
File added late
This file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release file before installing.
| Download URL | pyrsb-0.2.20210303-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl |
|---|---|
| Size | 6.0 MB |
| Tags | CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
f7a5b4cf5d26476cd084ad894e2826179fdc1b9a59f3f89fc5b51c622ea2e684
|
|
BLAKE2b-256 checksum How to use checksums |
db00f6942ca9a22765efbc9f05b2a6020d463fdf6044c5715cf0f7c0c7178958
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.2
|
Release files / pyrsb-0.2.20210303-cp37-cp37m-manylinux2010_x86_64.whl
| Download URL | pyrsb-0.2.20210303-cp37-cp37m-manylinux2010_x86_64.whl |
|---|---|
| Size | 3.6 MB |
| Tags | CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
3856e15bb26bb94546d150e49fe43bd42e1126dbe90952637858a9619a46df5b
|
|
BLAKE2b-256 checksum How to use checksums |
7d8d891691d98dc37ea8c6a465db2d167687faa2963e7ab9f95550261304176e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.2
|
Release files / pyrsb-0.2.20210303-cp36-cp36m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
File added late
This file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release file before installing.
| Download URL | pyrsb-0.2.20210303-cp36-cp36m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl |
|---|---|
| Size | 6.0 MB |
| Tags | CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
113596c9387c46f2d5a00351b04bd8b4e15cbf1ff7a39bea179d8bd6fb4e280e
|
|
BLAKE2b-256 checksum How to use checksums |
18cd5930a08354a2ef014c7d62b87f1fb3f08540844a7eb289e3d1fe1297e940
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.2
|
Release files / pyrsb-0.2.20210303-cp36-cp36m-manylinux2010_x86_64.whl
| Download URL | pyrsb-0.2.20210303-cp36-cp36m-manylinux2010_x86_64.whl |
|---|---|
| Size | 3.6 MB |
| Tags | CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
53b32cb2bc42c6926272aa4eb85ce0f145f6be568e6890b4484c537669aaee89
|
|
BLAKE2b-256 checksum How to use checksums |
24e5883a0d85f644f76d8ec374d636312e704cda9fff9425197ff65bcb8988d9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.2
|