Skip to main content

Structured matrices

Project description

Structured Matrices

CI Coverage Status Latest Docs Code style: black

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.ones(3))

>>> d
<diagonal matrix: shape=3x3, data type=float64,
 diag=[1. 1. 1.]>
  
>>> 2 * d
<diagonal matrix: shape=3x3, data type=float64
 diag=[2. 2. 2.]>

>>> 2 * d + 1
<Woodbury matrix: shape=3x3, dtype=int64
 diag=<diagonal matrix: shape=3x3, dtype=float64
       diag=[2. 2. 2.]>
 lr=<low-rank matrix: shape=3x3, dtype=int64, rank=1, sign=1
     left=[[1]
           [1]
           [1]]
     middle=<diagonal matrix: shape=1x1, dtype=int64
             diag=[1]>>>
  
>>> B.inv(2 * d + 1)
<Woodbury matrix: shape=3x3, dtype=float64
 diag=<diagonal matrix: shape=3x3, dtype=float64
       diag=[0.5 0.5 0.5]>
 lr=<low-rank matrix: shape=3x3, dtype=float64, rank=1, sign=0
     left=<dense matrix: shape=3x1, dtype=float64
           mat=[[0.5]
                [0.5]
                [0.5]]>
     middle=[[-0.4]]
     right=<dense matrix: shape=3x1, dtype=float64
            mat=[[0.5]
                 [0.5]
                 [0.5]]>>>

>>> B.kron(d, 2 * d)
<Kronecker product: shape=9x9, dtype=float64
 left=<diagonal matrix: shape=3x3, dtype=float64
       diag=[1. 1. 1.]>
 right=<diagonal matrix: shape=3x3, dtype=float64
        diag=[2. 2. 2.]>>


>>> B.inv(B.kron(d, 2 * d))
<Kronecker product: shape=9x9, dtype=float64
 left=<diagonal matrix: shape=3x3, dtype=float64
       diag=[1. 1. 1.]>
 right=<diagonal matrix: shape=3x3, dtype=float64
        diag=[0.5 0.5 0.5]>>

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

Functions

The following functions are added to LAB. They can be accessed with B.<function> where import lab as B.

dense(a)
fill_diag(a, diag_len)
block(*rows)

matmul_diag(a, b, tr_a=False, tr_b=False)
iqf(a, b, c)
iqf_diag(a, b, c)
ratio(a, c)
root(a)
sample(a, num=1)

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

backends-matrix-0.2.2.tar.gz (34.4 kB view details)

Uploaded Source

File details

Details for the file backends-matrix-0.2.2.tar.gz.

File metadata

  • Download URL: backends-matrix-0.2.2.tar.gz
  • Upload date:
  • Size: 34.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0.post20200814 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.6.10

File hashes

Hashes for backends-matrix-0.2.2.tar.gz
Algorithm Hash digest
SHA256 ff90db0a8263721b49359dc4b6bfde410a8a8f8591c3ab6073d07c2ad552cfed
MD5 bc5c56ec221005cec76da8ad122b5dbf
BLAKE2b-256 c3de0beb2b0a163c9fbb7e96588e07c379443f2f0f059630a24a3c2b712ab94d

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