The VPMR Algorithm
Project description
VPMR C++ Implementation
Call For Help
- more performant parallel SVD algorithm:
eigen
only provides sequential SVD - alternative integration: currently only Gauss-Legendre quadrature is available
What Is This?
This is a C++ implementation of the VPMR algorithm to compute the approximation of arbitrary smooth kernel. A Python package is also provided.
Check the reference paper 10.1007/s10915-022-01999-1 and the original MATLAB implementation for more details.
Dependency
- gmp for multiple precision arithmetic
- mpfr for multiple-precision floating-point computations
- mpreal
mpreal
type C++ wrapper, included - BigInt
BigInt
arbitrary large integer for combinatorial number, included - Eigen for matrix decomposition, included
- tbb for parallel computing
- exprtk for expression parsing, included
- exprtk-custom-types for
mpreal
support, included
How To
Python Package
[!WARNING] The Python module needs external libraries to be installed.
[!WARNING] Windows users need to have a working MSYS2 environment. See below for more details. For other environments, you need to figure out how to install
gmp
andmpfr
on your own.
On RPM-based Linux distributions (using dnf
), if you are:
- compiling the application from source (or wheels are not
available),
sudo dnf install -y gcc-c++ tbb-devel mpfr-devel gmp-devel
- using the packaged binary (wheels are available),
sudo dnf install -y gmp mpfr tbb
On macOS, you need to brew install tbb mpfr gmp
.
Then install the package with pip
.
pip install pyvpmr
If the corresponding wheel is not available, the package will be compiled, which takes a few minutes.
The execution of the algorithm always requires available gmp
, mpfr
and tbb
libraries.
Jumpstart
import numpy as np
from pyvpmr import vpmr, plot
def kernel(x):
return np.exp(-x ** 2 / 4)
if __name__ == '__main__':
m, s = vpmr(n=50, k='exp(-t^2/4)')
plot(m, s, kernel)
Compile Binary
[!WARNING] The application relies on
eigen
andexprtk
, which depend on very heavy usage of templates. The compilation would take minutes and around 2 GB memory. You need to install librariesgmp
,mpfr
andtbb
before compiling.
Windows
Use the following instructions based on MSYS2, or follow the Linux instructions below with WSL.
# install necessary packages
pacman -S git mingw-w64-x86_64-cmake mingw-w64-x86_64-tbb mingw-w64-x86_64-gcc mingw-w64-x86_64-ninja mingw-w64-x86_64-gmp mingw-w64-x86_64-mpfr
# clone the repository
git clone --depth 1 https://github.com/TLCFEM/vpmr.git
# initialise submodules
cd vpmr
git submodule update --init --recursive
# apply patch to enable parallel evaluation of some loops in SVD
cd eigen && git apply --ignore-space-change --ignore-whitespace ../patch_size.patch && cd ..
# configure and compile
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release .
ninja
Linux
The following is based on Fedora.
sudo dnf install gcc g++ gfortran cmake git -y
sudo dnf install tbb-devel mpfr-devel gmp-devel -y
git clone --depth 1 https://github.com/TLCFEM/vpmr.git
cd vpmr
git submodule update --init --recursive
cd eigen && git apply --ignore-space-change --ignore-whitespace ../patch_size.patch && cd ..
cmake -DCMAKE_BUILD_TYPE=Release .
make
Usage
All available options are:
Usage: vpmr [options]
Options:
-n <int> number of terms (default: 10)
-d <int> number of precision bits (default: 512)
-q <int> quadrature order (default: 500)
-m <int> precision multiplier (default: 6)
-nc <int> controls the maximum exponent (default: 4)
-e <float> tolerance (default: 1E-8)
-k <string> file name of kernel function (default: exp(-t^2/4))
-s print singular values
-w print weights
-h print this help message
Example
The default kernel is exp(-t^2/4)
. One can run the application with the following command:
./vpmr -n 30
The output is:
Using the following parameters:
nc = 4.
n = 30.
order = 500.
precision = 336.
tolerance = 1.0000e-08.
kernel = exp(-t*t/4).
[1/6] Computing weights... [60/60]
[2/6] Solving Lyapunov equation...
[3/6] Solving SVD...
[4/6] Transforming (P=+9)...
[5/6] Solving eigen decomposition...
[6/6] Done.
M =
+1.1745193571738943e+01-1.4261645574068720e-100j
-5.5143304351134397e+00+5.7204056791636839e+00j
-5.5143304351134397e+00-5.7204056791636839e+00j
-1.6161617424833762e-02+2.3459542440459513e+00j
-1.6161617424833762e-02-2.3459542440459513e+00j
+1.6338578576177487e-01+1.9308431539218418e-01j
+1.6338578576177487e-01-1.9308431539218418e-01j
-5.4905134221689715e-03+2.2104939243740062e-03j
-5.4905134221689715e-03-2.2104939243740062e-03j
S =
+1.8757961592204051e+00-0.0000000000000000e+00j
+1.8700580506914817e+00+6.2013413918954552e-01j
+1.8700580506914817e+00-6.2013413918954552e-01j
+1.8521958553280000e+00-1.2601975249082220e+00j
+1.8521958553280000e+00+1.2601975249082220e+00j
+1.8197653300065935e+00+1.9494562062795735e+00j
+1.8197653300065935e+00-1.9494562062795735e+00j
+1.7655956664692953e+00-2.7555720406099038e+00j
+1.7655956664692953e+00+2.7555720406099038e+00j
Running time: 3 s.
Arbitrary Kernel
For arbitrary kernel, it is necessary to provide the kernel function in a text file.
The file should contain the kernel expressed as a function of variable t
.
The exprtk
is used to parse the expression and compute the value.
The provided kernel function must be valid and supported by exprtk
.
For example, to compute the approximation of exp(-t^2/10)
, one can create a file kernel.txt
with the following
content:
exp(-t*t/10)
In the following, the kernel function is echoed to a file and then used as an input to the application.
echo "exp(-t*t/10)" > kernel.txt
./vpmr -n 60 -k kernel.txt -e 1e-12
Binary
The binary requires available gmp
, mpfr
and tbb
libraries.
❯ ldd vpmr
linux-vdso.so.1 (0x00007ffcf3121000)
libgmp.so.10 => /lib64/libgmp.so.10 (0x00007f72087e8000)
libmpfr.so.6 => /lib64/libmpfr.so.6 (0x00007f7208736000)
libtbb.so.2 => /lib64/libtbb.so.2 (0x00007f72086f2000)
libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f7208400000)
libm.so.6 => /lib64/libm.so.6 (0x00007f7208320000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f72086d0000)
libc.so.6 => /lib64/libc.so.6 (0x00007f7208143000)
/lib64/ld-linux-x86-64.so.2 (0x00007f72088a1000)
The distributed appimage
is portable.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for pyvpmr-231126-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc07aa8356e586adbc401907139810e256d382520a9ca6827c8c7a4b32a068d3 |
|
MD5 | b8c1fc3974b198e144f39d704d90195c |
|
BLAKE2b-256 | 7fc295470ca16f2558464f1f7d6e54c3c82c74bf516980058e0f53f75e790f50 |
Hashes for pyvpmr-231126-pp310-pypy310_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7c2f4a6c3412b866fc2a662d520708fc8914f254db55f2edcee993f6d538e21 |
|
MD5 | 86c4fd1a8a44c82d0a7576ae1612ed5e |
|
BLAKE2b-256 | 3960ba7d387780309852803b65ae089640f7c377ee36edd27fbab3109aeffb02 |
Hashes for pyvpmr-231126-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca17af16653dc48b0294ddd7c8e1a4451ced1c678820d412bc8379155c3b1699 |
|
MD5 | d9b4a7011ad22dc492da4f75a36e1753 |
|
BLAKE2b-256 | 6c38e1efd89cc55f364e1bca86488693770d6527879adc566eee211d82ee22db |
Hashes for pyvpmr-231126-pp39-pypy39_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cfa8d7b8e371ca6042da6e1d2f354e6478030c1fce55449b94d8c8c776b6b23e |
|
MD5 | 105d5824b8ea3b4e1907ce13a48b2b7d |
|
BLAKE2b-256 | f3511efa71ec789ca761d14224ab865eb846349593991dec27903b0fdfe1fb1c |
Hashes for pyvpmr-231126-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ead80de93776907f866dbd25155f26d512dffd2c6cb80046e30b6c91cfb411a6 |
|
MD5 | 63f87326dfebbb132fdc02d4ec4dfe1f |
|
BLAKE2b-256 | 0bb76a1ee768f91acda51cac1d72bf06d5ecb051e1c4f430cdd944efc336968b |
Hashes for pyvpmr-231126-pp38-pypy38_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff7051c1ba142ddb8f796a053311d62214bdb83393b2ae5a2af4e1fb0e6b1f38 |
|
MD5 | 6987bdd4cac978f608cbba15f9dc577e |
|
BLAKE2b-256 | 52badcf7e627c2834dfe699afd68af115809192c8a3de80c7bb176f63505ecda |
Hashes for pyvpmr-231126-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98634a1141df237b904b546e7a537c03cf9494c7ca8bbbcc1e5ce2f14e94f958 |
|
MD5 | 8fa1b68f670351fed28e4b678bd09748 |
|
BLAKE2b-256 | 2cd473e461276cd678fb2b0cb14225b61335a7d76d9b6af5f6c97df9261ccf9e |
Hashes for pyvpmr-231126-pp37-pypy37_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1da5e0f7517834e6bfc8ddf03016c223f8b41b25254f4d8ce5c045d3a01c8f8 |
|
MD5 | acf1c1510f651509bc5fac4ceb3a25c7 |
|
BLAKE2b-256 | 1a7f3cb647c4b85248d59bb476eca6b04586eb3893943370656355c1fe1a1255 |
Hashes for pyvpmr-231126-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | df9e0d3efe629f1b588601fe9276906efa2c84d9a3c4aa3ab422601acdeee282 |
|
MD5 | 3abd7d5a6db33321270748684556d7ad |
|
BLAKE2b-256 | ba53c56f861f2c6feaff49faba7a98d182042f31676213a0d888ffe1874b8759 |
Hashes for pyvpmr-231126-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc0f4a8e3fd1548d632bf8dfefa2fb723fd42e80ad821c1537f4660353569b50 |
|
MD5 | 43d54522c9e1867b106e5dce6708c263 |
|
BLAKE2b-256 | d582d3ef64092f492cf135f7ffc9e9ee19c48323653bc9e6bc48cb2257ff5777 |
Hashes for pyvpmr-231126-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9eece95d25df1b17ed71cacb63598e5ee7ffb2bde5005a04ea2e6d65f78c1a6 |
|
MD5 | 36c75b2f44da61a5569665e6960eac18 |
|
BLAKE2b-256 | e58ffa06b8bfcc132fb8bcd0558471bfce273d613c8908f7c364d829dc48dc4b |
Hashes for pyvpmr-231126-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 56c6607ba0d0e130e37a5a5bc2c9599a92c8cc0b38b824ff8f6370ed736c06a7 |
|
MD5 | 558093b07bc36e16b3909366ee9554c8 |
|
BLAKE2b-256 | efe0c400df9042c124189098b39d46835da7da3b0dddd738a3c00730b8683f43 |
Hashes for pyvpmr-231126-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08f07f4117cfc79a8c09743013de468a9815b3af20122162c092d3a137a9f676 |
|
MD5 | ee91a2bbe905304dc72a78af1deb2715 |
|
BLAKE2b-256 | 8c4f4da18ddf3042b8b0ad9ec322c93467e9feb1aa832e6e504cda1a48f09355 |
Hashes for pyvpmr-231126-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b779134fab208d987540a10181224cebbb7179083ffcce14d1d2dc25053db25 |
|
MD5 | 947aa1062bad876fc8329da883a0e8dc |
|
BLAKE2b-256 | d3958f26dd74da4ca5e98cfad2747285743eefe1184319ee6049880adab1a2b1 |
Hashes for pyvpmr-231126-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1a2ac415612fef09222a3dcbc732084b334b4dce469d476d1c446fba7e1b84d |
|
MD5 | f5e62d579dd246f3665f36c9041c21f4 |
|
BLAKE2b-256 | d1da16f7603cd6a5ec5b9a6a1528d74407d2363b9738a5b6587f0137b2c28ffb |
Hashes for pyvpmr-231126-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49880093f95f83b548c880f136508bde29446eb0667b417c216814bcaf77ed84 |
|
MD5 | f14373040cc8db128f000ca380459215 |
|
BLAKE2b-256 | 6c9daefff641b68f4158b6ce7e1988cc0fbc5e2e5172128acb066023df53815c |
Hashes for pyvpmr-231126-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f748793352b2fd040e41ade026d2542c5ee9a1bd759f5f92988f88b39a2e9e9 |
|
MD5 | 91bb7b7e6ceabd3a39e45260e23bfe12 |
|
BLAKE2b-256 | 25acec46be77b3624063cb28ba087ff125ecd47cb3d91d0f8f521fde7453ecb1 |
Hashes for pyvpmr-231126-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4296336dd895756974d919e0d6160889d2fc9ea6f47674ce9ec5df35e144a7d7 |
|
MD5 | e6d8888ef1b5656de67cfe8a1aef5532 |
|
BLAKE2b-256 | 018c68b28cd1947b80e08f4a80609a3f7c3434ee187b9f66a2aa52e233e828fe |
Hashes for pyvpmr-231126-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89e8c28528f026a10ef6593eb17c181e9cd006653c35923a9d9962cfc7c64b01 |
|
MD5 | e671e2c581cfae119cfa7d76768ffcdc |
|
BLAKE2b-256 | 8f5240d0603d68631ffa39ae45bf5d946e482f421ed1cff39bbe5237b81bb917 |
Hashes for pyvpmr-231126-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4f9b917a97ae22e185886b13ade6b5626ff3e45d8f3c15e11ee7c2d4ab39130 |
|
MD5 | ed8254b8683a701db692239d8d7d7853 |
|
BLAKE2b-256 | 1034dadc87a902ab08938950ac1b06ceed46928082fa02c029d05485b2151969 |