# Spark (mathematics)

In mathematics, more specifically in linear algebra, the spark of a $m\times n$ matrix $A$ is the smallest integer $k$ such that there exists a set of $k$ columns in $A$ which are linearly dependent. If all the columns are linearly independent, $\mathrm {spark} (A)$ is usually defined to be 1 more than the number of rows. The concept of matrix spark finds applications in error-correction codes, compressive sensing, and matroid theory, and provides a simple criterion for maximal sparsity of solutions to a system of linear equations.
The spark of a matrix is NP-hard to compute.

## Definition

Formally, the spark of a matrix $A$ is defined as follows:
| $\mathrm {spark} (A)=\min _{d\neq 0}\|d\|_{0}{\text{ s.t. }}Ad=0$ | (Eq.1) |
where $d$ is a nonzero vector and $\|d\|_{0}$ denotes its number of nonzero coefficients ($\|d\|_{0}$ is also referred to as the size of the support of a vector). Equivalently, the spark of a matrix $A$ is the size of its smallest circuit $C$ (a subset of column indices such that $A_{C}x=0$ has a nonzero solution, but every subset of it does not).
If all the columns are linearly independent, $\mathrm {spark} (A)$ is usually defined to be $m+1$ (if $A$ has m rows).
By contrast, the rank of a matrix is the largest number $k$ such that some set of $k$ columns of $A$ is linearly independent.

## Example

Consider the following matrix $A$.
$A={\begin{bmatrix}1&2&0&1\\1&2&0&2\\1&2&0&3\\1&0&-3&4\end{bmatrix}}$
The spark of this matrix equals 3 because:
* There is no set of 1 column of $A$ which are linearly dependent.
* There is no set of 2 columns of $A$ which are linearly dependent.
* But there is a set of 3 columns of $A$ which are linearly dependent. The first three columns are linearly dependent because ${\begin{pmatrix}1\\1\\1\\1\end{pmatrix}}-{\frac {1}{2}}{\begin{pmatrix}2\\2\\2\\0\end{pmatrix}}+{\frac {1}{3}}{\begin{pmatrix}0\\0\\0\\-3\end{pmatrix}}={\begin{pmatrix}0\\0\\0\\0\end{pmatrix}}$.

## Properties

If $n\geq m$, the following simple properties hold for the spark of a $m\times n$ matrix $A$:
* $\mathrm {spark} (A)=m+1\Rightarrow \mathrm {rank} (A)=m$ (If the spark equals $m+1$, then the matrix has full rank.)
* $\mathrm {spark} (A)=1$ if and only if the matrix has a zero column.
* $\mathrm {spark} (A)\leq \mathrm {rank} (A)+1$.

## Criterion for uniqueness of sparse solutions

The spark yields a simple criterion for uniqueness of sparse solutions of linear equation systems. Given a linear equation system $A\mathbf {x} =\mathbf {b}$. If this system has a solution $\mathbf {x}$ that satisfies $\|\mathbf {x} \|_{0}<{\frac {\mathrm {spark} (A)}{2}}$, then this solution is the sparsest possible solution. Here $\|\mathbf {x} \|_{0}$ denotes the number of nonzero entries of the vector $\mathbf {x}$.

## Lower bound in terms of dictionary coherence

If the columns of the matrix $A$ are normalized to unit norm, we can lower bound its spark in terms of its dictionary coherence:
    $\mathrm {spark} (A)\geq 1+{\frac {1}{\mu (A)}}$.
Here, the dictionary coherence $\mu (A)$ is defined as the maximum correlation between any two columns:
    $\mu (A)=\max _{m\neq n}|\langle a_{m},a_{n}\rangle |=\max _{m\neq n}{\frac {|a_{m}^{\intercal }a_{n}|}{||a_{m}||_{2}||a_{n}||_{2}}}$.

## Applications

The minimum distance of a linear code equals the spark of its parity-check matrix.
The concept of the spark is also of use in the theory of compressive sensing, where requirements on the spark of the measurement matrix are used to ensure stability and consistency of various estimation techniques. It is also known in matroid theory as the girth of the vector matroid associated with the columns of the matrix. The spark of a matrix is NP-hard to compute.