[SciPy-dev] An addition to basic.py
Nils Wagner
nwagner at mecha.uni-stuttgart.de
Wed Apr 20 10:02:47 CDT 2005
Hi all,
it would be nice if the following function could be added to basic.py in
/Lib/linalg
from scipy import *
def vec(a):
"""vec function of the matrix a is the vector formed by stacking
the columns of a on top of one another
Reference: Alan J. Laub, Matrix Analysis for Scientists & Engineers
SIAM 2005
"""
if not a.iscontiguous():
a = reshape(a, a.shape)
return concatenate(transpose(a))
#
# A short test
#
a = rand(3,3)
b = rand(3,3)
c = rand(3,3)
d = dot(a,dot(b,c))
x1 = vec(d)
x2 = dot(linalg.kron(transpose(c),a),vec(b))
print 'x1-x2 should be zero',linalg.norm(x1-x2)
Nils
More information about the Scipy-dev
mailing list