Jan. 31, 2008
3:08 a.m.
Try the function below (from pyGAUSS). hth, Alan Isaac #diagrv: insert v as diagonal of matrix x (2D only!) def diagrv(x,v,copy=True): assert(len(x.shape)==2), "For 2-d arrays only." x = numpy.matrix( x, copy=copy ) stride = 1 + x.shape[1] x.flat[ slice(0,None,stride) ] = v return x