# pierreablin / qndiag

Quasi-Newton algorithm for joint-diagonalization
Python MATLAB Makefile Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information. examples matlab_octave qndiag .gitignore .travis.yml LICENSE MANIFEST.in Makefile README.md setup.py

# Quasi-Newton algorithm for joint-diagonalization

## Summary

This Python package contains code for fast joint-diagonalization of a set of positive definite symmetric matrices. The main function is `qndiag`, which takes as input a set of matrices of size `(p, p)`, stored as a `(n, p, p)` array, `C`. It outputs a `(p, p)` array, `B`, such that the matrices `B @ C[i] @ B.T` (python), ie `B * C(i,:,:) * B'` (matlab/octave) are as diagonal as possible.

## Installation of Python package

To install the package, do:

`\$ pip install -U https://api.github.com/repos/pierreablin/qndiag/master`

You can also simply clone it, and then do:

`\$ pip install -e .`

To check that everything worked, the command

`\$ python -c 'import qndiag'`

should not return any error.

## Use with Python

Here is a toy example (also available at `examples/toy_example.py`)

```import numpy as np
from qndiag import qndiag

n, p = 10, 3
diagonals = np.random.uniform(size=(n, p))
A = np.random.randn(p, p)  # mixing matrix
C = np.array([A.dot(d[:, None] * A.T) for d in diagonals])  # dataset

B, _ = qndiag(C)  # use the algorithm

print(B.dot(A))  # Should be a permutation + scale matrix```

## Use with Matlab or Octave

See `qndiag.m` and `toy_example.m` in the folder `matlab_octave`.

## Cite

If you use this code please cite:

``````P. Ablin, J.F. Cardoso and A. Gramfort. Beyond Pham’s algorithm
for joint diagonalization. Proc. ESANN 2019.
https://www.elen.ucl.ac.be/Proceedings/esann/esannpdf/es2019-119.pdf
https://hal.archives-ouvertes.fr/hal-01936887v1
https://arxiv.org/abs/1811.11433
``````
You can’t perform that action at this time.