Name | pygensvd JSON |
Version |
0.1.0
JSON |
| download |
home_page | |
Summary | Python and NumPy extension module implementing the generalized signular value decomposition (GSVD). |
upload_time | 2023-06-27 02:31:49 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.7 |
license | GNU License |
keywords |
gsvd
|
VCS |
|
bugtrack_url |
|
requirements |
numpy
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# `pygensvd.py`
An updated version of the original pygsvd package by Benjamin Naecker. This version
uses cmake for compilation rather than distutils, but only supports openblas as a backend (for now).
A Python wrapper to the LAPACK generalized singular value decomposition.
(C) 2017 Benjamin Naecker bnaecker@fastmail.com
## Overview
The `pygsvd` module exports a single function `gsvd`, which computes the
generalized singular value decomposition (GSVD) of a pair of matrices,
`A` and `B`. The [GSVD](https://en.wikipedia.org/wiki/Generalized_singular_value_decomposition)
is a joint decomposition useful for computing regularized solutions
to ill-posed least-squares problems, as well as dimensionality reduction
and clustering.
The `pygsvd` module is very simple: it just wraps the underlying LAPACK
routine `ggsvd3`, both the double-precision (`dggsvd3`) and complex-double
precision versions (`zggsvd3`).
## Building
Because the `pygsvd` module wraps a LAPACK routine itself, it is provided
as a Python and NumPy extension module. The module must be compiled,
and doing so requires a LAPACK header and a shared library. The module
currently supports both the standard C bindings to LAPACK (called
[LAPACKE](http://www.netlib.org/lapack/lapacke.html)),
and those provided by Intel's Math Kernel Library. Notably it does *not*
support Apple's Accelerate framework, which seems to be outdated and
differs in several subtle and annoying ways.
You can build against either of the supported implementations, by editing
the `setup.cfg` file. Set the `define=` line in the file to be one of
`USE_LAPACK` (the default) or `USE_MKL`.
You must also add the include and library directories for these. The
build process already searches `/usr/local/{include,lib}`, but if these
don't contain the header and library, add the directory containing these
to the `include_dirs=` and `library_dirs=` line. Multiple directories are
separated by a `:`. You can also set these on the command line when building.
For example, to use the LAPACK library, with a header in `/some/dir/`
and the library in `/some/libdir/`, you could run:
$ python3 setup.py build_ext --include-dirs="/some/dir" --library-dirs="/some/libdir"
Then you can install the module either as usual or in develop mode as:
$ python3 setup.py {install,develop}
Or via `pip` as:
$ pip3 install .
## Usage
The GSVD of a pair of NumPy ndarrays `a` and `b` can be computed as:
>>> c, s, x = pygsvd.gsvd(a, b)
This returns the generalized singular values, in arrays `c` and `s`, and the
right generalized singular vectors in `x`. Optionally, the transformation matrices
`u` and` `v` may also be computed. E.g.:
>>> c, s, x, u = pygsvd.gsvd(a, b, extras='u')
also returns the left generalized singular vectors of `a`.
By default, the matrices `u` and `v`, if returned, are of shape `(m, n)` and
`(p, n)`. Using the optional argument `full_matrices` is set to `True`, then
the matrices are square, of shape `(m, m)` and `(p, p)`.
## The generalized singular value decomposition
The GSVD is a joint decomposition of a pair of matrices. Given matrices
`A` with shape `(m, n)` and `B` with shape `(p, n)`, it computes:
A = U*C*X.T
B = V*S*X.T
where `U` and `V` are unitary matrices, with shapes `(m, m)` and `(p, p)`,
and `X` is shaped as `(n, n)`, respectively. `C` and `S` are diagonal (possibly non-square)
matrices containing the generalized singular value pairs.
This decomposition has many uses, including least-squares fitting of ill-posed
problems. For example, letting `B` be the "second derivative" operator one can
solve the equation
min_x ||Ax - b||^2 + \lambda ||Bx||^2
using the GSVD, which achieves a smoother solution as `\lambda` is increased.
Similarly, setting `B` to the identity matrix, this becomes the standard
ridge regression problem. These are both versions of the Tichonov regularization
problem, for which the GSVD provides a useful and efficient solution.
Raw data
{
"_id": null,
"home_page": "",
"name": "pygensvd",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "GSVD",
"author": "",
"author_email": "Andrew Van <vanandrew@wustl.edu>",
"download_url": "https://files.pythonhosted.org/packages/97/14/7fb79dc6a86fb0b2f061beeac84eae9316c196cbce75941df876f91c2c4e/pygensvd-0.1.0.tar.gz",
"platform": null,
"description": "# `pygensvd.py`\n\nAn updated version of the original pygsvd package by Benjamin Naecker. This version\nuses cmake for compilation rather than distutils, but only supports openblas as a backend (for now).\n\nA Python wrapper to the LAPACK generalized singular value decomposition.\n\n(C) 2017 Benjamin Naecker bnaecker@fastmail.com\n\n## Overview\n\nThe `pygsvd` module exports a single function `gsvd`, which computes the\ngeneralized singular value decomposition (GSVD) of a pair of matrices,\n`A` and `B`. The [GSVD](https://en.wikipedia.org/wiki/Generalized_singular_value_decomposition)\nis a joint decomposition useful for computing regularized solutions\nto ill-posed least-squares problems, as well as dimensionality reduction\nand clustering.\n\nThe `pygsvd` module is very simple: it just wraps the underlying LAPACK\nroutine `ggsvd3`, both the double-precision (`dggsvd3`) and complex-double\nprecision versions (`zggsvd3`).\n\n## Building\n\nBecause the `pygsvd` module wraps a LAPACK routine itself, it is provided\nas a Python and NumPy extension module. The module must be compiled,\nand doing so requires a LAPACK header and a shared library. The module\ncurrently supports both the standard C bindings to LAPACK (called \n[LAPACKE](http://www.netlib.org/lapack/lapacke.html)),\nand those provided by Intel's Math Kernel Library. Notably it does *not*\nsupport Apple's Accelerate framework, which seems to be outdated and\ndiffers in several subtle and annoying ways.\n\nYou can build against either of the supported implementations, by editing \nthe `setup.cfg` file. Set the `define=` line in the file to be one of \n`USE_LAPACK` (the default) or `USE_MKL`.\n\nYou must also add the include and library directories for these. The\nbuild process already searches `/usr/local/{include,lib}`, but if these\ndon't contain the header and library, add the directory containing these\nto the `include_dirs=` and `library_dirs=` line. Multiple directories are\nseparated by a `:`. You can also set these on the command line when building.\n\nFor example, to use the LAPACK library, with a header in `/some/dir/`\nand the library in `/some/libdir/`, you could run:\n\n\t$ python3 setup.py build_ext --include-dirs=\"/some/dir\" --library-dirs=\"/some/libdir\"\n\nThen you can install the module either as usual or in develop mode as:\n\n \t$ python3 setup.py {install,develop}\n\nOr via `pip` as:\n\n\t$ pip3 install .\n\n## Usage\n\nThe GSVD of a pair of NumPy ndarrays `a` and `b` can be computed as:\n\n\t>>> c, s, x = pygsvd.gsvd(a, b)\n\nThis returns the generalized singular values, in arrays `c` and `s`, and the\nright generalized singular vectors in `x`. Optionally, the transformation matrices\n`u` and` `v` may also be computed. E.g.:\n\n\t>>> c, s, x, u = pygsvd.gsvd(a, b, extras='u')\n\nalso returns the left generalized singular vectors of `a`.\n\nBy default, the matrices `u` and `v`, if returned, are of shape `(m, n)` and\n`(p, n)`. Using the optional argument `full_matrices` is set to `True`, then\nthe matrices are square, of shape `(m, m)` and `(p, p)`.\n\n## The generalized singular value decomposition\n\nThe GSVD is a joint decomposition of a pair of matrices. Given matrices\n`A` with shape `(m, n)` and `B` with shape `(p, n)`, it computes:\n\n A = U*C*X.T\n B = V*S*X.T\n\nwhere `U` and `V` are unitary matrices, with shapes `(m, m)` and `(p, p)`,\nand `X` is shaped as `(n, n)`, respectively. `C` and `S` are diagonal (possibly non-square)\nmatrices containing the generalized singular value pairs.\n\nThis decomposition has many uses, including least-squares fitting of ill-posed\nproblems. For example, letting `B` be the \"second derivative\" operator one can\nsolve the equation\n\n\tmin_x ||Ax - b||^2 + \\lambda ||Bx||^2\n\nusing the GSVD, which achieves a smoother solution as `\\lambda` is increased.\nSimilarly, setting `B` to the identity matrix, this becomes the standard\nridge regression problem. These are both versions of the Tichonov regularization\nproblem, for which the GSVD provides a useful and efficient solution.\n",
"bugtrack_url": null,
"license": "GNU License",
"summary": "Python and NumPy extension module implementing the generalized signular value decomposition (GSVD).",
"version": "0.1.0",
"project_urls": {
"github": "https://github.com/vanandrew/pygensvd"
},
"split_keywords": [
"gsvd"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "64b1af2ba7e1963900fffe1424f55c54f6752d9a453eb0a450049095e381c571",
"md5": "ff795c13a4ad00f1f4ce205a2c83d354",
"sha256": "7c9c4e145e8a09202279660d1885246fac58f181750ac47a0d1de7937c1ace05"
},
"downloads": -1,
"filename": "pygensvd-0.1.0-cp310-cp310-macosx_10_9_x86_64.whl",
"has_sig": false,
"md5_digest": "ff795c13a4ad00f1f4ce205a2c83d354",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.7",
"size": 11582162,
"upload_time": "2023-06-27T02:31:15",
"upload_time_iso_8601": "2023-06-27T02:31:15.773887Z",
"url": "https://files.pythonhosted.org/packages/64/b1/af2ba7e1963900fffe1424f55c54f6752d9a453eb0a450049095e381c571/pygensvd-0.1.0-cp310-cp310-macosx_10_9_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "78ee2d85d6a20620dc20a0aababe1e530ebac41e24e6e05e428dc5c57803efa4",
"md5": "8ec170d7e5ad344018ef7149ed24617d",
"sha256": "1c5c56e725cd089277a687f9bb741b0cfefc07f28bffce6f4779795fb95852e5"
},
"downloads": -1,
"filename": "pygensvd-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"has_sig": false,
"md5_digest": "8ec170d7e5ad344018ef7149ed24617d",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.7",
"size": 11020859,
"upload_time": "2023-06-27T02:31:18",
"upload_time_iso_8601": "2023-06-27T02:31:18.920418Z",
"url": "https://files.pythonhosted.org/packages/78/ee/2d85d6a20620dc20a0aababe1e530ebac41e24e6e05e428dc5c57803efa4/pygensvd-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f03de7ab23b03df862d7f0575444a39eb379e44712da932635a8b1a3c703ce87",
"md5": "b1efc88c186de92875cabf9eb816c408",
"sha256": "6464e660ef9d814e2af5fad959ab909134caab15342e8de55357af64c82b598c"
},
"downloads": -1,
"filename": "pygensvd-0.1.0-cp311-cp311-macosx_10_9_x86_64.whl",
"has_sig": false,
"md5_digest": "b1efc88c186de92875cabf9eb816c408",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.7",
"size": 11582169,
"upload_time": "2023-06-27T02:31:22",
"upload_time_iso_8601": "2023-06-27T02:31:22.335364Z",
"url": "https://files.pythonhosted.org/packages/f0/3d/e7ab23b03df862d7f0575444a39eb379e44712da932635a8b1a3c703ce87/pygensvd-0.1.0-cp311-cp311-macosx_10_9_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "629c2335e2805e4e5b08df278a1d6479dc05fbd962b5dff9ca04897e233b91e5",
"md5": "119abc7fbf521336609b5787ab908f62",
"sha256": "1e31c359bd0615e1e9de551225d3d5c81289cba51a2932c1121c51b4ccefc61e"
},
"downloads": -1,
"filename": "pygensvd-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"has_sig": false,
"md5_digest": "119abc7fbf521336609b5787ab908f62",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.7",
"size": 11020881,
"upload_time": "2023-06-27T02:31:26",
"upload_time_iso_8601": "2023-06-27T02:31:26.474609Z",
"url": "https://files.pythonhosted.org/packages/62/9c/2335e2805e4e5b08df278a1d6479dc05fbd962b5dff9ca04897e233b91e5/pygensvd-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5df2ac2f5afdcd6feb136eaa81a1a913e52d9d9b733a70a85ea45c98cb6a08e8",
"md5": "c120595c9f8d1c1a85948d7ee65b183a",
"sha256": "d1f7c232cc1a2d1b5caac1e131aa4b81662728c90f431be5aa9a0d114f0484fb"
},
"downloads": -1,
"filename": "pygensvd-0.1.0-cp37-cp37m-macosx_10_9_x86_64.whl",
"has_sig": false,
"md5_digest": "c120595c9f8d1c1a85948d7ee65b183a",
"packagetype": "bdist_wheel",
"python_version": "cp37",
"requires_python": ">=3.7",
"size": 11581973,
"upload_time": "2023-06-27T02:31:29",
"upload_time_iso_8601": "2023-06-27T02:31:29.504141Z",
"url": "https://files.pythonhosted.org/packages/5d/f2/ac2f5afdcd6feb136eaa81a1a913e52d9d9b733a70a85ea45c98cb6a08e8/pygensvd-0.1.0-cp37-cp37m-macosx_10_9_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "94571417605322b2e4a01cedad660b102fcf402d08c8af19693c6230f6667139",
"md5": "a63006a838f80932ecba7d9a575e7ff2",
"sha256": "e7db5355116858d55a151c4415a89f974fa13770160da7715ab3823343233fa1"
},
"downloads": -1,
"filename": "pygensvd-0.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"has_sig": false,
"md5_digest": "a63006a838f80932ecba7d9a575e7ff2",
"packagetype": "bdist_wheel",
"python_version": "cp37",
"requires_python": ">=3.7",
"size": 11020649,
"upload_time": "2023-06-27T02:31:32",
"upload_time_iso_8601": "2023-06-27T02:31:32.274021Z",
"url": "https://files.pythonhosted.org/packages/94/57/1417605322b2e4a01cedad660b102fcf402d08c8af19693c6230f6667139/pygensvd-0.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "44982e7692d06e3e1522d554e3cb7793087838f86badbb9e61b3c5bde232f734",
"md5": "334fd1b1fd349b120dbfc7034cabc2ee",
"sha256": "a6a40781ebd6fafef50fcb5ead725ed1bd95132b5eebc2d3b1f34a010b378979"
},
"downloads": -1,
"filename": "pygensvd-0.1.0-cp38-cp38-macosx_10_9_x86_64.whl",
"has_sig": false,
"md5_digest": "334fd1b1fd349b120dbfc7034cabc2ee",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.7",
"size": 11582264,
"upload_time": "2023-06-27T02:31:35",
"upload_time_iso_8601": "2023-06-27T02:31:35.368280Z",
"url": "https://files.pythonhosted.org/packages/44/98/2e7692d06e3e1522d554e3cb7793087838f86badbb9e61b3c5bde232f734/pygensvd-0.1.0-cp38-cp38-macosx_10_9_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b01ad5f81f011ebe23656419451dc5a6acbd702340a6247340b3dc4aaade56e4",
"md5": "f87b84f26c7da78c0dda5c4bedb82d37",
"sha256": "78885cbeab4568ff8b85383a135ec9f37087edf39ae763194cac4e694f172ee4"
},
"downloads": -1,
"filename": "pygensvd-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"has_sig": false,
"md5_digest": "f87b84f26c7da78c0dda5c4bedb82d37",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.7",
"size": 11020903,
"upload_time": "2023-06-27T02:31:41",
"upload_time_iso_8601": "2023-06-27T02:31:41.277519Z",
"url": "https://files.pythonhosted.org/packages/b0/1a/d5f81f011ebe23656419451dc5a6acbd702340a6247340b3dc4aaade56e4/pygensvd-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "be9b23b32e27994dd684852306adc346586bb0ba423b9effaa9acb78c63dd587",
"md5": "a522ff6ac8b1d3b41fdffe5c257af162",
"sha256": "642765da943df098df101de8aced46a4b9a9c476dc1d3e2df4a917c117931b3a"
},
"downloads": -1,
"filename": "pygensvd-0.1.0-cp39-cp39-macosx_10_9_x86_64.whl",
"has_sig": false,
"md5_digest": "a522ff6ac8b1d3b41fdffe5c257af162",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": ">=3.7",
"size": 11582157,
"upload_time": "2023-06-27T02:31:44",
"upload_time_iso_8601": "2023-06-27T02:31:44.246495Z",
"url": "https://files.pythonhosted.org/packages/be/9b/23b32e27994dd684852306adc346586bb0ba423b9effaa9acb78c63dd587/pygensvd-0.1.0-cp39-cp39-macosx_10_9_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1b78617fb2f730ed51c828c38b522d94bf4d6ccee9bfa317e850ca35452737cc",
"md5": "4677514f000f1ba1bfd00884e5dc95c8",
"sha256": "2bded7671052f2428dae559d440d7156dab46e93762e66ed4832b11efe4f425b"
},
"downloads": -1,
"filename": "pygensvd-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"has_sig": false,
"md5_digest": "4677514f000f1ba1bfd00884e5dc95c8",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": ">=3.7",
"size": 11020856,
"upload_time": "2023-06-27T02:31:47",
"upload_time_iso_8601": "2023-06-27T02:31:47.115231Z",
"url": "https://files.pythonhosted.org/packages/1b/78/617fb2f730ed51c828c38b522d94bf4d6ccee9bfa317e850ca35452737cc/pygensvd-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "97147fb79dc6a86fb0b2f061beeac84eae9316c196cbce75941df876f91c2c4e",
"md5": "c1a62e5d690564510025e0f011f5ec08",
"sha256": "c6857fa0522e1899673729c250eddb987f14cbd515ab33e958e98d81feb6016c"
},
"downloads": -1,
"filename": "pygensvd-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "c1a62e5d690564510025e0f011f5ec08",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 10743,
"upload_time": "2023-06-27T02:31:49",
"upload_time_iso_8601": "2023-06-27T02:31:49.335746Z",
"url": "https://files.pythonhosted.org/packages/97/14/7fb79dc6a86fb0b2f061beeac84eae9316c196cbce75941df876f91c2c4e/pygensvd-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-06-27 02:31:49",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "vanandrew",
"github_project": "pygensvd",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "numpy",
"specs": [
[
">=",
"1.1"
]
]
}
],
"lcname": "pygensvd"
}