MichielStock / Kronecker.jl

A general-purpose toolbox for efficient Kronecker-based algebra.
MIT License
86 stars 14 forks source link

Kronecker.jl

This is a Julia package to efficiently work with Kronecker products. It combines lazy evaluation and algebraic tricks such that it can implicitely work with huge matrices. It allows to work with large Kronecker systems both much faster and using much less memory than the naive implementation of the Kronecker product.

Features

Given two matrices (subtype of AbstractArray) A and B, one can construct an instance of the KroneckerProduct type as K = A ⊗ B (typed using \otimes TAB). Equivalently, the function kronecker function can be used as well. Several functions are implemented.

Read the documentation to get the specifics.

Benchmarks

Below is a comparision between the native kron function and Kronecker.jl for several operations.

Example

using Kronecker

A = randn(100, 100);
B = rand(50, 50);

v = rand(5000);

K = A ⊗ B

collect(K)  # equivalent with kron(A, B)

K[78, 43]

tr(K)
inv(K)  # yields another lazy Kronecker instance

K * v  # equivalent with vec(B * reshape(v, 50, 100) * A')

See the notebook for some more advanced use.

Installation

Directly available via the Julia package manager:

] add Kronecker

Issues

This is very much a work in progress! Please start an issue for bugs or requests to improve functionality. Any feedback is appreciated!

Status master branch

stable docsdev docsbuild status coverage DOIJULIACON