Structured Matrices
Structured matrices
Requirements and Installation
See the instructions here. Then simply
pip install backends-matrix
Example
>>> import lab as B
>>> from matrix import Diagonal
>>> d = Diagonal(B.rand(2, 3)) # A batch of diagonal marices
>>> d
<diagonal matrix: batch=(2,), shape=(3, 3), dtype=float64
diag=[[0.427 0.912 0.622]
[0.777 0.048 0.808]]>
>>> 2 * d
<diagonal matrix: batch=(2,), shape=(3, 3), dtype=float64
diag=[[0.854 1.824 1.243]
[1.553 0.096 1.616]]>
>>> 2 * d + 1
<Woodbury matrix: batch=(2,), shape=(3, 3), dtype=float64
diag=<diagonal matrix: batch=(2,), shape=(3, 3), dtype=float64
diag=[[0.854 1.824 1.243]
[1.553 0.096 1.616]]>
lr=<low-rank matrix: batch=(), shape=(3, 3), dtype=int64, rank=1
left=[[1]
[1]
[1]]
middle=<diagonal matrix: batch=(), shape=(1, 1), dtype=int64
diag=[1]>>>
>>> B.inv(2 * d + 1)
<Woodbury matrix: batch=(2,), shape=(3, 3), dtype=float64
diag=<diagonal matrix: batch=(2,), shape=(3, 3), dtype=float64
diag=[[ 1.171 0.548 0.804]
[ 0.644 10.386 0.619]]>
lr=<low-rank matrix: batch=(2,), shape=(3, 3), dtype=float64, rank=1
left=<dense matrix: batch=(2,), shape=(3, 1), dtype=float64
mat=[[[ 1.171]
[ 0.548]
[ 0.804]]
[[ 0.644]
[10.386]
[ 0.619]]]>
middle=<dense matrix: batch=(2,), shape=(1, 1), dtype=float64
mat=[[[-0.284]]
[[-0.079]]]>
right=<dense matrix: batch=(2,), shape=(3, 1), dtype=float64
mat=[[[ 1.171]
[ 0.548]
[ 0.804]]
[[ 0.644]
[10.386]
[ 0.619]]]>>>
>>> B.inv(B.inv(2 * d + 1))
<Woodbury matrix: batch=(2,), shape=(3, 3), dtype=float64
diag=<diagonal matrix: batch=(2,), shape=(3, 3), dtype=float64
diag=[[0.854 1.824 1.243]
[1.553 0.096 1.616]]>
lr=<low-rank matrix: batch=(2,), shape=(3, 3), dtype=float64, rank=1
left=<dense matrix: batch=(2,), shape=(3, 1), dtype=float64
mat=[[[1.]
[1.]
[1.]]
[[1.]
[1.]
[1.]]]>
middle=<dense matrix: batch=(2,), shape=(1, 1), dtype=float64
mat=[[[1.]]
[[1.]]]>
right=<dense matrix: batch=(2,), shape=(3, 1), dtype=float64
mat=[[[1.]
[1.]
[1.]]
[[1.]
[1.]
[1.]]]>>>
>>> B.inv(B.inv(2 * d + 1)) - 1
<diagonal matrix: batch=(2,), shape=(3, 3), dtype=float64
diag=[[0.854 1.824 1.243]
[1.553 0.096 1.616]]>
Matrix Types
All matrix types are subclasses of AbstractMatrix.
The following base types are provided:
Zero
Dense
Diagonal
Constant
LowerTriangular
UpperTriangular
The following composite types are provided:
LowRank
Woodbury
Kronecker
TiledBlocks
Functions
The following functions are added to LAB.
They can be accessed with B.<function> where import lab as B.
shape_broadcast(*elements)
shape_batch(a, *indices)
shape_batch_broadcast(*elements)
shape_matrix(a, *indices)
shape_matrix_broadcast(*elements)
broadcast_batch_to(a, *batch)
dense(a)
fill_diag(a, diag_len)
block(*rows)
block_diag(*blocks)
matmul_diag(a, b, tr_a=False, tr_b=False)
pd_inv(a)
schur(a)
pd_schur(a)
iqf(a, b, c)
iqf_diag(a, b, c)
ratio(a, c)
root(a)
sample(a, num=1)
Metadata
Release files for backends-matrix 1.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| backends-matrix-1.3.0.tar.gz | 56.6 kB | Without provenance | Details for backends-matrix-1.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| backends_matrix-1.3.0-py3-none-any.whl | Python 3 | none | any | Details for backends_matrix-1.3.0-py3-none-any.whl |
Total release size: 155.5 kB
Release files / backends-matrix-1.3.0.tar.gz
| Download URL | backends-matrix-1.3.0.tar.gz |
|---|---|
| Size | 56.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4c6ca5aafbf51d6a3d715c0419da172d3f3d74f97121fa736d2db1d2d385798b
|
|
BLAKE2b-256 checksum How to use checksums |
105f51914fb9dfc22342976c2a32e7a2ff42af6f47cbe311308e23750ec0ab23
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|
Release files / backends_matrix-1.3.0-py3-none-any.whl
| Download URL | backends_matrix-1.3.0-py3-none-any.whl |
|---|---|
| Size | 98.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5d34ba44069aef2d154d74fbef216556818efa8f59e5b9d60b3c30eb983f3f29
|
|
BLAKE2b-256 checksum How to use checksums |
1a8ce4f32b8d9cddf404fd8effa6ad4760278795e6e97502d9a9e578b19b3993
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|
Security for backends-matrix 1.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.