Skip to main content

VPMR C++ Implementation

DOI codecov

gplv3-or-later

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.

Check the reference paper 10.1007/s10915-022-01999-1 and the original MATLAB implementation for more details.

Dependency

  1. gmp for multiple precision arithmetic
  2. mpfr for multiple-precision floating-point computations
  3. mpreal mpreal type C++ wrapper, included
  4. BigInt BigInt arbitrary large integer for combinatorial number, included
  5. Eigen for matrix decomposition, included
  6. tbb for parallel computing
  7. exprtk for expression parsing, included
  8. exprtk-custom-types for mpreal support, included

How To

Python Package

[!WARNING] The Python module needs external libraries to be installed.

On RPM-based Linux distributions (using dnf), if you are:

  1. compiling the application from source (or wheels are not available), sudo dnf install -y gcc-c++ tbb-devel mpfr-devel gmp-devel
  2. using the packaged binary (wheels are available), sudo dnf install -y gmp mpfr tbb

Then install the package with pip.

pip install pyvpmr

Compile

[!WARNING] The application relies on eigen and exprtk, which depend on very heavy usage of templates. The compilation would take minutes and around 2 GB memory. You need to install libraries gmp, mpfr and tbb 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 digits (default: 512)
   -q <int>     quadrature order (default: 500)
   -m <int>     digit 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.

exp(-t^2/4)

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

exp(-t^2/10)

Visualisation

The plotter folder contains a Python script to plot the result.

It is necessary to have click, matplotlib and numpy available in, for example, the virtual environment.

The usage is similar:

Usage: plotter.py [OPTIONS]

Options:
  -n INTEGER   number of terms
  -q INTEGER   quadrature order
  -d INTEGER   number of precision digits
  -nc INTEGER  controls the maximum exponents
  -e FLOAT     tolerance
  -o TEXT      save plot to file
  -k TEXT      file name of kernel function
  --exe TEXT   path to vpmr executable
  --help       Show this message and exit.

[!Note] Remember to change the kernel function so that the plot is meaningful.

# change this kernel before plotting
def kernel(x):
    return np.exp(-x * x / 4)

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.

Metadata

Release files for pyvpmr 231124

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyvpmr 231124
File Size Uploaded
pyvpmr-231124.tar.gz 5.4 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for pyvpmr 231124
File
pyvpmr-231124-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl PyPy 3.10 PyPy 3.10 7.3 Linux glibc 2.28+ x86-64 Details
pyvpmr-231124-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl PyPy 3.9 PyPy 3.9 7.3 Linux glibc 2.28+ x86-64 Details
pyvpmr-231124-pp38-pypy38_pp73-manylinux_2_28_x86_64.whl PyPy 3.8 PyPy 3.8 7.3 Linux glibc 2.28+ x86-64 Details
pyvpmr-231124-pp37-pypy37_pp73-manylinux_2_28_x86_64.whl PyPy 3.7 PyPy 3.7 7.3 Linux glibc 2.28+ x86-64 Details
pyvpmr-231124-cp312-cp312-manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64 Details
pyvpmr-231124-cp311-cp311-manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64 Details
pyvpmr-231124-cp310-cp310-manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64 Details
pyvpmr-231124-cp39-cp39-manylinux_2_28_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.28+ x86-64 Details
pyvpmr-231124-cp38-cp38-manylinux_2_28_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.28+ x86-64 Details
pyvpmr-231124-cp37-cp37m-manylinux_2_28_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.28+ x86-64 Details

Total release size: 37.3 MB

Release files / pyvpmr-231124.tar.gz

Download URL pyvpmr-231124.tar.gz
Size 5.4 MB
Tags Source
SHA-256 checksum
How to use checksums
3d98fa317b1243cba72bc968e1432f7dc781cd273b5bc2fd7eed8c5990400af2
BLAKE2b-256 checksum
How to use checksums
6959f81ea408b4dda54b9bdcfc4b34bb5bbeaaf352a9ab6897ac771aa736b159
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Release files / pyvpmr-231124-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl

Download URL pyvpmr-231124-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl
Size 3.1 MB
Tags Linux glibc 2.28+ x86-64 PyPy 3.10 PyPy 3.10 7.3
SHA-256 checksum
How to use checksums
172cfc320301fdc2510f541d1cb55dc51a483ad11e445d1b2937627f47cb3092
BLAKE2b-256 checksum
How to use checksums
e58a0c1f22c9cc23a16f29f04b541f42cc75fd82235e1c700466f66706572bf3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Release files / pyvpmr-231124-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl

Download URL pyvpmr-231124-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl
Size 3.1 MB
Tags Linux glibc 2.28+ x86-64 PyPy 3.9 PyPy 3.9 7.3
SHA-256 checksum
How to use checksums
2a269c7a3ac39e8e79d9cc9583f81736103be63f1d8fb94dcbee18824b2156bf
BLAKE2b-256 checksum
How to use checksums
57fcc5a8da106e8c7c7fe586cdeb861f38e190428e1db5f0ff25fcbb66419e05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Release files / pyvpmr-231124-pp38-pypy38_pp73-manylinux_2_28_x86_64.whl

Download URL pyvpmr-231124-pp38-pypy38_pp73-manylinux_2_28_x86_64.whl
Size 3.1 MB
Tags Linux glibc 2.28+ x86-64 PyPy 3.8 PyPy 3.8 7.3
SHA-256 checksum
How to use checksums
321a8faab7b8f003f20419d2125085bbaefd3563893767a47b26251c69baa148
BLAKE2b-256 checksum
How to use checksums
5834e00743ff3b9223c3bd4773fd473e9c16f6e6bb789aa554463bc11379dfe6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Release files / pyvpmr-231124-pp37-pypy37_pp73-manylinux_2_28_x86_64.whl

Download URL pyvpmr-231124-pp37-pypy37_pp73-manylinux_2_28_x86_64.whl
Size 3.1 MB
Tags Linux glibc 2.28+ x86-64 PyPy 3.7 PyPy 3.7 7.3
SHA-256 checksum
How to use checksums
b49808a394e78c0598c895327d5fd0e2afa250f92fdb7c1a17e8749322e0e219
BLAKE2b-256 checksum
How to use checksums
f69dafb2c478f374233ffe58275b9af9d2c7bb5fe9f6d9bd21bc283b45d0710a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Release files / pyvpmr-231124-cp312-cp312-manylinux_2_28_x86_64.whl

Download URL pyvpmr-231124-cp312-cp312-manylinux_2_28_x86_64.whl
Size 3.2 MB
Tags CPython 3.12 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
66d998338570e852321e4b8b731ff981dc1f23e0029f06f6168c443c414a9f91
BLAKE2b-256 checksum
How to use checksums
d004c7ff1c71027dd78b66e12bf9086e0d03ebc8f4efe2832eebe4ec5c881627
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Release files / pyvpmr-231124-cp311-cp311-manylinux_2_28_x86_64.whl

Download URL pyvpmr-231124-cp311-cp311-manylinux_2_28_x86_64.whl
Size 3.2 MB
Tags CPython 3.11 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
209484f5536bd068f75e65580cef053f5345d1f886219a69b2db14241b7f89c0
BLAKE2b-256 checksum
How to use checksums
10fbe78de755df2e25ed1a3062cc90307e03f03e6a6073ea1f8e9bead954aee7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Release files / pyvpmr-231124-cp310-cp310-manylinux_2_28_x86_64.whl

Download URL pyvpmr-231124-cp310-cp310-manylinux_2_28_x86_64.whl
Size 3.2 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
6c3a56537a395063b46204329e985d07ebae135822650865237d9c7ae50607d9
BLAKE2b-256 checksum
How to use checksums
32eaca8988904daece94bf1a429ba345af615eeeeb7cdebda145b77b4f48e1ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Release files / pyvpmr-231124-cp39-cp39-manylinux_2_28_x86_64.whl

Download URL pyvpmr-231124-cp39-cp39-manylinux_2_28_x86_64.whl
Size 3.2 MB
Tags CPython 3.9 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
3da77abe45f3079ce490ea6543e0adc8b51505b0f2c441d07471450922600ddc
BLAKE2b-256 checksum
How to use checksums
7be0b5002e3ca90d64227aa04688bc809e1203388018fc6d73e022492d6c9075
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Release files / pyvpmr-231124-cp38-cp38-manylinux_2_28_x86_64.whl

Download URL pyvpmr-231124-cp38-cp38-manylinux_2_28_x86_64.whl
Size 3.2 MB
Tags CPython 3.8 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
78c2b70a0bf22fd9d7268fe4f1d333159ef5b6367edb22856a85c6730c4889d1
BLAKE2b-256 checksum
How to use checksums
318a7de0742e0c568df6ba825d4a649f5e62583bdbe372d395a9a9301647da06
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Release files / pyvpmr-231124-cp37-cp37m-manylinux_2_28_x86_64.whl

Download URL pyvpmr-231124-cp37-cp37m-manylinux_2_28_x86_64.whl
Size 3.2 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
e65d5f1cb09c97da34d18833d3e1e34c0c6399adb04de6c52ae26fc63efbe0ae
BLAKE2b-256 checksum
How to use checksums
4bb66e247f781a385ebbfb19b0b2231a69e7de3923484c52d3ec704b22d5b190
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Release history Release notifications | RSS feed

241011

7 release files

240921

7 release files

240916

7 release files

This release

231124 This release

11 release files

0

32 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page