[Numpy-discussion] Kronecker product
Nils Wagner
nwagner at isd.uni-stuttgart.de
Thu Jul 19 02:16:42 CDT 2001
Charles G Waldman schrieb:
> Nils Wagner writes:
> >
> > How can I rearrange the result of outerproduct to the result of
> > Kronecker product with numpy ?
> >
>
> def kron(a,b):
> o = outerproduct(a,b)
> o.shape = a.shape + b.shape
> return concatenate(concatenate(o, axis=1), axis=1)
What is the difference between kron(z,eye) and kron(yt,eye) ?
Nils
-------------- next part --------------
from Numeric import *
def kron(a,b):
o = outerproduct(a,b)
o.shape = a.shape + b.shape
return concatenate(concatenate(o, axis=1), axis=1)
y = array(([5,6,7],[8,9,10]))
print 'y'
print
print y
print
z = array(([5,8],[6,9],[7,10]))
print 'z'
print
print z
print
yt = transpose(y)
print 'yt'
print
print yt
print
eye = identity(2)
a = kron(y,eye)
print
print 'kron(y,eye)'
print
print a
print
b = kron(z,eye)
print
print 'kron(z,eye)'
print
print b
print
c = kron(yt,eye)
print
print c
print
More information about the Numpy-discussion
mailing list