# [Scipy-tickets] [SciPy] #313: Support for Kronecker sum

SciPy scipy-tickets at scipy.net
Thu Nov 23 02:16:06 CST 2006

```#313: Support for Kronecker sum
--------------------------+-------------------------------------------------
Reporter:  nils          |       Owner:  somebody
Type:  enhancement   |      Status:  new
Priority:  normal        |   Milestone:
Component:  scipy.linalg  |     Version:  devel
Severity:  normal        |    Keywords:
--------------------------+-------------------------------------------------
A definition of the Kronecker sum is given in the recent book by Alan J.
Laub
'''Matrix Analysis for Scientists and Engineers''' SIAM (2005).
{{{
def kronsum(a,b):
"""kronecker sum of a and b

Kronecker sum of two matrices is a sum
of two Kronecker products kron(I_m,a)+kron(b,I_n)

Inputs:

a -- An n x n matrix.
b -- An m x m matrix
"""
a1 = asarray_chkfinite(a)
if len(a1.shape) != 2 or a1.shape[0] != a1.shape[1]:
raise ValueError, 'expected square matrix'
b1 = asarray_chkfinite(b)
if len(b1.shape) != 2 or b1.shape[0] != b1.shape[1]:
raise ValueError, 'expected square matrix'

return
linalg.kron(identity(b1.shape[0]),a)+linalg.kron(b,identity(a1.shape[0]))
}}}

--
Ticket URL: <http://projects.scipy.org/scipy/scipy/ticket/313>
SciPy <http://www.scipy.org/>
SciPy is open-source software for mathematics, science, and engineering.
```