Skip to main content

Faster linear algebra with multiple precision

Project description

flamp - Faster linear algebra with multiple precision Build Status

flamp contains ports of many real and complex linear algebra routines from the mpmath package, but using numpy object arrays containing gmpy2 multiprecision floating point numbers instead of the mpmath floating point numbers. The resulting linear algebra routines are typically by a factor of 10x-15x faster than those in mpmath.

flamp is based on mpmath by Fredrik Johansson and the matrix algorithms by Timo Hartmann contained therein. flamp is BSD-licensed.

Installation

The package is written in pure Python and can simply be installed by

pip install flamp

Its only dependencies are numpy and gmpy2, both of which have pre-built packages readily available.

List of functions

The following is a list of supported functions in the flamp module by category. All matrix and vector arguments should be supplied as numpy arrays of gmpy2 numbers, although standard floating point numpy arrays will be automatically converted in most cases.

Refer to the docstrings for further information.

Linear algebra

These behave essentially like the corresponding functions in mpmath, with some slight modifications. For instance, all functions for solving linear systems accept either a single vector or an array of vectors for the right-hand side.

  • lu_solve(A, b) - solve a linear system using LU decomposition
  • qr_solve(A, b) - solve a linear system using QR decomposition
  • cholesky_solve(A, b) - solve a symmetric positive definite system using Cholesky decomposition
  • L_solve(L, b, unit_diag=False) - solve a lower triangular system
  • U_solve(U, y) - solve an upper triangular system
  • inverse(A) - compute inverse of a square matrix
  • det(A) - compute determinant of a square matrix
  • lu(A) - compute LU decomposition of a square matrix
  • qr(A, mode='full') - compute QR decomposition of a matrix; mode=full, reduced, raw
  • cholesky(A) - compute Cholesky decomposition of a symmetric positive definite matrix
  • eig(A, left=False, right=True) - compute eigenvalues and (optionally) left and right eigenvectors of a matrix
  • eigh(A, eigvals_only=False) - compute eigenvalues and (optionally) the orthonormal eigenvectors of a real symmetric or complex Hermitian square matrix
  • hessenberg(A) - compute Hessenberg decomposition (Q, R) of a square matrix
  • schur(A) - compute Schur decomposition of a square matrix
  • svd(A, full_matrices=False, compute_uv=True) - compute singular value decomposition (singular values and optionally the left and right singular vectors) of a matrix

Array functions

Most of these behave essentially like their numpy counterparts, but work with gmpy2 extended precision numbers.

  • zeros(shape)
  • ones(shape)
  • empty(shape)
  • eye(n)
  • linspace(start, stop, num, endpoint=True)
  • vector_norm(x) - computes Euclidean norm of a vector
  • to_mp(A) - converts an arbitrary numpy array (or list/tuple) into an array of gmpy2 numbers, copying the input

Utility functions

These functions are used to manipulate the working precision of the gmpy2 library.

  • prec_to_dps(n) - number of accurate decimals that can be represented with a precision of n bits
  • dps_to_prec(n) - number of bits required to represent n decimals accurately
  • get_precision() - get the current precision in binary digits
  • set_precision(prec) - set the working precision in binary digits
  • get_dps() get the current precision in decimal digits (approximate)
  • set_dps(dps) - set the working precision in decimal digits (approximate)
  • extraprec(n) - returns a context manager (for use in a with statement) which temporarily increases the working precision by the given amount

Array-aware special functions

These functions work much like the corresponding functions in numpy in that they automatically distribute over numpy arrays while computing in extended precision.

  • exp(x)
  • sqrt(x)
  • sin(x)
  • cos(x)
  • tan(x)
  • sinh(x)
  • cosh(x)
  • tanh(x)
  • square(x)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flamp-1.0.0.tar.gz (27.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flamp-1.0.0-py3-none-any.whl (26.8 kB view details)

Uploaded Python 3

File details

Details for the file flamp-1.0.0.tar.gz.

File metadata

  • Download URL: flamp-1.0.0.tar.gz
  • Upload date:
  • Size: 27.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.11

File hashes

Hashes for flamp-1.0.0.tar.gz
Algorithm Hash digest
SHA256 becd07795e70729ed369c6960e7f8527b071e78c25d7bcb16c7bc3cc712fb992
MD5 30c5a166c4f8cda4fd5c1e17a8d5fe12
BLAKE2b-256 42a5ed7c8d1c4fb19fc14bd9ba2dac2466052dac7a42915ce4feefad1b811eae

See more details on using hashes here.

File details

Details for the file flamp-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: flamp-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 26.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.11

File hashes

Hashes for flamp-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dcc58a8066e2eca8d77084951de81bcaa8d45e9b546230e6232f13a4d3cd488a
MD5 4341370dfa70f444b55b3953a1cb1869
BLAKE2b-256 aa474ec6aef75cea849216bb7854905726204eda7e6f3fb814a1139aab9b567c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page