Skip to main content

®️ rlinalg Stars

Linear Algebra routines for Python as implemented in the R language.

Actions Coverage License PyPI Bioconda Wheel Python Versions Python Implementations Source Mirror GitHub issues Docs Changelog Downloads

🗺️ Overview

The R Project for Statistical Computing provides an environment for using and developing statistical methods. Most of the array manipulation and linear algebra routines are implemented using LAPACK, which can be accessed in Python using SciPy and NumPy.

However, when trying to port and reproduce code from R in Python, one can notice differences in the implementation of several routines, in particular in the QR decomposition with pivoting enabled:

> mat <- t(matrix(seq_len(9), nrow=3))
> qr.Q(mat)
           [,1]       [,2]       [,3]
[1,] -0.1230915  0.9045340  0.4082483
[2,] -0.4923660  0.3015113 -0.8164966
[3,] -0.8616404 -0.3015113  0.4082483
>>> mat = numpy.arange(1, 10).reshape(3, 3)
>>> scipy.linalg.qr(mat, pivoting = True)[0]
array([[-0.2672612  0.8728716  0.4082483]
       [-0.5345225  0.2182179 -0.8164966]
       [-0.8017837 -0.4364358  0.4082483]])

The culprit here is the qr function from R not using LAPACK dgeqp3 by default, but a modified R-specific version of the LINPACK dqrdc routine (dqrdc2) that optimizes the pivoting strategy. This means that code using qr in R will behave differently than an equivalent Python using LAPACK, and there was (until now) no way to reproduce the R behaviour.

The rlinalg library provides linear algebra routines from R using the Fortran sources to allow reproducibility. It exposes an API similar to the scipy interface for similar functions (qr, cond, lstsq), which can be used to get the same results as R:

>>> mat = numpy.arange(1, 10).reshape(3, 3)
>>> rlinalg.qr(mat).Q.round(7)
array([[-0.1230915  0.904534   0.4082483]
       [-0.492366   0.3015113 -0.8164966]
       [-0.8616404 -0.3015113  0.4082483]])

This library depends on NumPy, and on the BLAS libraries available on the system. It is available for all modern Python versions (3.7+). Building is done with Meson and requires a Fortran compiler when compiling from source.

🔧 Installing

Install the rlinalg package directly from PyPi which hosts universal wheels that can be installed with pip:

$ pip install rlinalg

💭 Feedback

⚠️ Issue Tracker

Found a bug? Have an enhancement request? Head over to the GitHub issue tracker if you need to report or ask something. If you are filing in on a bug, please include as much information as you can about the issue, and try to recreate the same bug in a simple, easily reproducible situation.

📋 Changelog

This project adheres to Semantic Versioning and provides a changelog in the Keep a Changelog format.

⚖️ License

This library is provided under the GNU General Public License v3.0 or later. It includes some code redistributed from the R language, which is licensed under the GNU General Public License v2.0 or later. Some tests were adapted from SciPy, which is developed under the BSD-3-clause license.

This project is in no way not affiliated, sponsored, or otherwise endorsed by the R project. It was developed by Martin Larralde during his PhD project at the Leiden University Medical Center in the Zeller lab.

Metadata

Release files for rlinalg 0.1.1

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

Source distribution (sdist)

Source distribution for rlinalg 0.1.1
File Size Uploaded
rlinalg-0.1.1.tar.gz 15.9 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for rlinalg 0.1.1
File
rlinalg-0.1.1-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl PyPy 3.10 PyPy 3.10 7.3 Linux glibc 2.28+ x86-64 Details
rlinalg-0.1.1-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl PyPy 3.9 PyPy 3.9 7.3 Linux glibc 2.28+ x86-64 Details
rlinalg-0.1.1-pp38-pypy38_pp73-manylinux_2_28_x86_64.whl PyPy 3.8 PyPy 3.8 7.3 Linux glibc 2.28+ x86-64 Details
rlinalg-0.1.1-pp37-pypy37_pp73-manylinux_2_28_x86_64.whl PyPy 3.7 PyPy 3.7 7.3 Linux glibc 2.28+ x86-64 Details
rlinalg-0.1.1-cp312-cp312-manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64 Details
rlinalg-0.1.1-cp311-cp311-manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64 Details
rlinalg-0.1.1-cp310-cp310-manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64 Details
rlinalg-0.1.1-cp39-cp39-manylinux_2_28_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.28+ x86-64 Details
rlinalg-0.1.1-cp38-cp38-manylinux_2_28_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.28+ x86-64 Details
rlinalg-0.1.1-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: 136.4 MB

Release files / rlinalg-0.1.1.tar.gz

Download URL rlinalg-0.1.1.tar.gz
Size 15.9 MB
Tags Source
SHA-256 checksum
How to use checksums
d8af86782666bfe9d1a5475549d1f0e52928739909dc42ffc71b084f25dda2c3
BLAKE2b-256 checksum
How to use checksums
5efd52c89af015f196a5c5797c070f706912c587c6a2852dc933146a7c8c9f43
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Release files / rlinalg-0.1.1-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl

Download URL rlinalg-0.1.1-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl
Size 12.0 MB
Tags Linux glibc 2.28+ x86-64 PyPy 3.10 PyPy 3.10 7.3
SHA-256 checksum
How to use checksums
657035fb74350e8e26ef36dbd7c78cdfff60d9f381f944781ac22cc61b2fd79e
BLAKE2b-256 checksum
How to use checksums
6e65c2aa83473b420e7f93ea6ffc7ebfdf5310db1733a689f8716ad9c65ceef1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Release files / rlinalg-0.1.1-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl

Download URL rlinalg-0.1.1-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl
Size 12.0 MB
Tags Linux glibc 2.28+ x86-64 PyPy 3.9 PyPy 3.9 7.3
SHA-256 checksum
How to use checksums
061914a5b2609fc5ea486908052407a8b084c427722af32c2539b84857dd3f4e
BLAKE2b-256 checksum
How to use checksums
73a4b26a78d9615605b3b609c07f477765b217cdd26b62a1c86129eafb09596c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Release files / rlinalg-0.1.1-pp38-pypy38_pp73-manylinux_2_28_x86_64.whl

Download URL rlinalg-0.1.1-pp38-pypy38_pp73-manylinux_2_28_x86_64.whl
Size 12.0 MB
Tags Linux glibc 2.28+ x86-64 PyPy 3.8 PyPy 3.8 7.3
SHA-256 checksum
How to use checksums
d170e69a17ce87db4697f44c5d9978af8670dee222c9530257266fd29a95f046
BLAKE2b-256 checksum
How to use checksums
04f8d260574822ef995ea98f3c55ce767ba1484399ee78c6fe8f93683d8e5e3b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Release files / rlinalg-0.1.1-pp37-pypy37_pp73-manylinux_2_28_x86_64.whl

Download URL rlinalg-0.1.1-pp37-pypy37_pp73-manylinux_2_28_x86_64.whl
Size 12.0 MB
Tags Linux glibc 2.28+ x86-64 PyPy 3.7 PyPy 3.7 7.3
SHA-256 checksum
How to use checksums
9a2226c1e7d05d0fe3b57c9be11b96779375ffcb0de432b5fd0949b62128739d
BLAKE2b-256 checksum
How to use checksums
a1b2374f0ad0e4e92333e043c2e21d05999eb1ab7ff56c36251b6370fdbda5bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Release files / rlinalg-0.1.1-cp312-cp312-manylinux_2_28_x86_64.whl

Download URL rlinalg-0.1.1-cp312-cp312-manylinux_2_28_x86_64.whl
Size 12.0 MB
Tags CPython 3.12 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
799e15a302310885f4eb13fd806a68d2fd17015391744bb84f841a1e94594d7e
BLAKE2b-256 checksum
How to use checksums
4570dc6a8da0c4726522fd5ed3d90b1bbe048fa6f6ab173cbd3c5963c1f4652b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Release files / rlinalg-0.1.1-cp311-cp311-manylinux_2_28_x86_64.whl

Download URL rlinalg-0.1.1-cp311-cp311-manylinux_2_28_x86_64.whl
Size 12.0 MB
Tags CPython 3.11 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
6f444f765504982120779e9e110ed0ec86c7db1ff3bb972663252ed474f40d59
BLAKE2b-256 checksum
How to use checksums
8c8eafd1d0a1ab3d01da15363b8e3e72b96e4818befbef13136867698c24430b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Release files / rlinalg-0.1.1-cp310-cp310-manylinux_2_28_x86_64.whl

Download URL rlinalg-0.1.1-cp310-cp310-manylinux_2_28_x86_64.whl
Size 12.0 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
be00753e1c3f31f0d0e6344778d24c92dfbb2060b3942e31b994e07bf3d6a430
BLAKE2b-256 checksum
How to use checksums
15468bf756e69bcd4b725fbc4c6a5f16e0f87a6dc41cea6a1650c71d8bf8ab51
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Release files / rlinalg-0.1.1-cp39-cp39-manylinux_2_28_x86_64.whl

Download URL rlinalg-0.1.1-cp39-cp39-manylinux_2_28_x86_64.whl
Size 12.0 MB
Tags CPython 3.9 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
e0d2181d825e163bdd355f57a98622ff0d346266df85f01a7dbc1cd3b80061e4
BLAKE2b-256 checksum
How to use checksums
77cf1e22247ef8dc54f41a6aa7eb688b94d38e0173bdfa37e3d45a0a2263c382
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Release files / rlinalg-0.1.1-cp38-cp38-manylinux_2_28_x86_64.whl

Download URL rlinalg-0.1.1-cp38-cp38-manylinux_2_28_x86_64.whl
Size 12.0 MB
Tags CPython 3.8 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
c50d7759c3123d8116f8ecb8d1d47eb6b33b68f913c48eb4ab48d4cfb79ed1b8
BLAKE2b-256 checksum
How to use checksums
e9e88603ef696885684d9df55dbe7e55fff82e23c60d0d0528ae8f37874d88d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Release files / rlinalg-0.1.1-cp37-cp37m-manylinux_2_28_x86_64.whl

Download URL rlinalg-0.1.1-cp37-cp37m-manylinux_2_28_x86_64.whl
Size 12.0 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
3841aa988ca252b5dd2c4341fb88bdbb4c02437d6aa6124dc4937b460cf5ddc5
BLAKE2b-256 checksum
How to use checksums
2b7ac613af747768359fd8ce469631c8bef6ff2e051b8f55a66759741cb8ba45
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Release history Release notifications | RSS feed

This release

0.1.1 This release

11 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