# Antisymmetric matrices?

**URL:** https://discourse.julialang.org/t/antisymmetric-matrices/75829
**Category:** General Usage
**Tags:** question, linearalgebra, sparse
**Created:** [February 4, 2022, 11:42pm UTC](https://discourse.julialang.org/t/antisymmetric-matrices/75829 "2022-02-04T23:42:34Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![akriegman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/akriegman/32/30573_2.png) [@akriegman](https://discourse.julialang.org/u/akriegman)
#### Post date: [February 4, 2022, 11:42pm UTC](https://discourse.julialang.org/t/antisymmetric-matrices/75829/1 "2022-02-04T23:42:34Z")

</div>

The `LinearAlgebra` module in the standard library has several special matrix types which represent various sparse matrix types, like symmetric or upper-triangular. This allows for reduced memory usage as you can avoid storing the same number twice or storing a bunch of zeros. It also allows for faster calculations in some cases by skipping multiplication by zero, and I think in some cases reusing the result of a multiplication?

I was surprised to find that `LinearAlgebra` does not include an antisymmetric matrix type (sometimes called skew-symmetric). I thought that was a pretty common special matrix type. So my question is what’s the idiomatic way to deal with antisymmetric matrices in Julia? Should I just make a dense matrix and not worry about it? Could / should I make my own sparse antisymmetric matrix implementation? (I didn’t see an existing implementation, but I didn’t look that hard either.)

---

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [February 4, 2022, 11:50pm UTC](https://discourse.julialang.org/t/antisymmetric-matrices/75829/2 "2022-02-04T23:50:14Z")

</div>

depending on what you need them for:  
[https://jump.dev/JuMP.jl/dev/manual/variables/#Example:-skew-symmetric-variables](https://jump.dev/JuMP.jl/dev/manual/variables/#Example:-skew-symmetric-variables)

---

<div class="post-metadata">

### Author: ![zdenek\_hurak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zdenek_hurak/32/53118_2.png) [@zdenek\_hurak](https://discourse.julialang.org/u/zdenek_hurak)
#### Post date: [February 5, 2022, 1:01am UTC](https://discourse.julialang.org/t/antisymmetric-matrices/75829/3 "2022-02-05T01:01:06Z")

</div>

Well, disregarding the restriction of this advice to optimization problems, it only allows for symmetric matrix **variables** and not symmetrix coefficient matrices. I cannot see how this could be use for solving, say, Ax=b for x\in\mathbb{R}^n while exploiting an antisymmetry of the coefficient matrix A.

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [February 5, 2022, 1:55am UTC](https://discourse.julialang.org/t/antisymmetric-matrices/75829/4 "2022-02-05T01:55:25Z")

</div>

There aren’t that many algorithms or software libraries to take advanage of anti-symmetric matrices; they seem to be a fairly specialized corner of numerical linear algebra. (None in LAPACK as far as I know.)

The one area where it would be nice to have an anti-symmetric matrix type, probably in a package, is for real-antisymmetric eigenvalue problems, which have nice properties (purely imaginary eigenvalues, orthogonal eigenvectors). You can turn them into Hermitian eigenproblems by multiplying by i, but then you pay the price of a complex matrix. (See also [these references](https://github.com/JuliaLang/julia/issues/21224#issuecomment-290422297) and the rest of that discussion, and also [this paper](https://arxiv.org/abs/1912.04062).)

There are also [Cholesky-like factorizations](https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.38.3872&rep=rep1&type=pdf) for solving Ax=b with anti-symmetric A, but it might take a lot of optimization effort for them to be competitive with the highly optimized LU factorization in LAPACK.

And there’s the [Pfaffian](https://en.wikipedia.org/wiki/Pfaffian) and [algorithms therefor](https://doi.org/10.1145/2331130.2331138).

All in all, it would be a good topic for a package. Maybe even a GSOC project?

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [February 5, 2022, 10:14pm UTC](https://discourse.julialang.org/t/antisymmetric-matrices/75829/5 "2022-02-05T22:14:57Z")

</div>

(A basic challenge here is that naive 3-loop implementations of dense-matrix algorithms tend to be 50x slower than optimized code like LAPACK with a fast BLAS. So you need to get pretty serious about software engineering for an antisymmetric algorithm to be worth it compared to just multiplying by i and using the complex-Hermitian routines.)
